com.helger.commons.collection.impl.CommonsHashMap Java Examples
The following examples show how to use
com.helger.commons.collection.impl.CommonsHashMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EqualsHashcodeFuncTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testMap () { final ICommonsMap <String, Object> aMap = new CommonsHashMap <> (); aMap.put ("foo", "bar"); _testEqualsHashcode (aMap); final ICommonsMap <String, Object> aTreeMap = new CommonsTreeMap <> (); aTreeMap.put ("foo", "bar"); aTreeMap.put ("foo2", Integer.valueOf (5)); _testEqualsHashcode (aTreeMap); final ICommonsMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> (); aLinkedMap.put ("foo", "bar"); aLinkedMap.put ("foo2", Integer.valueOf (5)); _testEqualsHashcode (aLinkedMap); }
Example #2
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 6 votes |
@Nonnull @ReturnsMutableCopy @SafeVarargs public static <ELEMENTTYPE> CommonsHashMap <ELEMENTTYPE, ELEMENTTYPE> newMap (@Nullable final ELEMENTTYPE... aValues) { if (ArrayHelper.isEmpty (aValues)) return newMap (0); if ((aValues.length % 2) != 0) throw new IllegalArgumentException ("The passed array needs an even number of elements!"); final CommonsHashMap <ELEMENTTYPE, ELEMENTTYPE> ret = newMap (aValues.length / 2); for (int i = 0; i < aValues.length; i += 2) ret.put (aValues[i], aValues[i + 1]); return ret; }
Example #3
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 6 votes |
@Nonnull @ReturnsMutableCopy public static <KEYTYPE, VALUETYPE> CommonsHashMap <KEYTYPE, VALUETYPE> newMap (@Nullable final KEYTYPE [] aKeys, @Nullable final VALUETYPE [] aValues) { final int nKeys = ArrayHelper.getSize (aKeys); final int nValues = ArrayHelper.getSize (aValues); // Check for identical size if (nKeys != nValues) throw new IllegalArgumentException ("The passed arrays have different length (" + nKeys + " keys and " + nValues + " values)!"); // Are both empty? if (nKeys == 0) return newMap (0); final CommonsHashMap <KEYTYPE, VALUETYPE> ret = newMap (nKeys); for (int i = 0; i < aKeys.length; ++i) ret.put (aKeys[i], aValues[i]); return ret; }
Example #4
Source File: StringHelperTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testReplaceMultipleMap () { final ICommonsMap <String, String> aMap = new CommonsHashMap <> (); aMap.put ("Hallo", "Hi"); aMap.put ("Welt", "world"); aMap.put ("!", "???"); assertEquals ("Abc die Katze lief im Schnee", StringHelper.replaceMultiple ("Abc die Katze lief im Schnee", aMap)); assertEquals ("Hi Katze", StringHelper.replaceMultiple ("Hallo Katze", aMap)); assertEquals ("Moin world", StringHelper.replaceMultiple ("Moin Welt", aMap)); assertEquals ("Moin welt", StringHelper.replaceMultiple ("Moin welt", aMap)); assertEquals ("Hi", StringHelper.replaceMultiple ("Hallo", aMap)); assertEquals ("Hi Hi", StringHelper.replaceMultiple ("Hallo Hallo", aMap)); assertEquals ("HiHiHi", StringHelper.replaceMultiple ("HalloHalloHallo", aMap)); assertEquals ("Hi world???", StringHelper.replaceMultiple ("Hallo Welt!", aMap)); assertEquals ("Hi world???Hi world???", StringHelper.replaceMultiple ("Hallo Welt!Hallo Welt!", aMap)); }
Example #5
Source File: EqualsHelperTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testMap () { final StringMap aMap = new StringMap ("a", "b").add ("c", "d"); assertTrue (EqualsHelper.equalsCollection (aMap, aMap)); assertTrue (EqualsHelper.equalsCollection (aMap, CollectionHelper.makeUnmodifiable (aMap))); assertTrue (EqualsHelper.equalsCollection (aMap, Collections.synchronizedMap (aMap))); assertTrue (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "d"))); assertTrue (EqualsHelper.equalsCollection (new CommonsHashMap <Integer, Integer> (), new CommonsHashMap <Double, Float> ())); assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashMap <Integer, Integer> ())); assertFalse (EqualsHelper.equalsCollection (new CommonsHashMap <Integer, Integer> (), aMap)); assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b"))); assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("A", "b").add ("c", "d"))); assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "B").add ("c", "d"))); assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("C", "d"))); assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "D"))); assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "d").add ("e", "f"))); assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsArrayList <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashSet <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aMap, ArrayHelper.newArray ("a", "b", "c"))); }
Example #6
Source File: BasicTreeItemWithID.java From ph-commons with Apache License 2.0 | 6 votes |
@Nonnull public final EChange internalAddChild (@Nonnull final KEYTYPE aDataID, @Nonnull final ITEMTYPE aChild, final boolean bAllowOverwrite) { ValueEnforcer.notNull (aChild, "Child"); // Ensure children are present if (m_aChildMap != null) { if (!bAllowOverwrite && m_aChildMap.containsKey (aDataID)) return EChange.UNCHANGED; } else { m_aChildMap = new CommonsHashMap <> (); m_aChildren = new CommonsArrayList <> (); } m_aChildMap.put (aDataID, aChild); m_aChildren.add (aChild); m_aFactory.onAddItem (aChild); return EChange.CHANGED; }
Example #7
Source File: JsonConverterTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testMap () { final ICommonsMap <String, Object> aMap = new CommonsHashMap <> (); aMap.put ("foo", "bar"); aMap.put ("foo2", Integer.valueOf (5)); assertTrue (JsonConverter.convertToJson (aMap) instanceof JsonObject); final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap <> (); aTreeMap.put ("foo", "bar"); aTreeMap.put ("foo2", Integer.valueOf (5)); assertTrue (JsonConverter.convertToJson (aTreeMap) instanceof JsonObject); final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> (); aLinkedMap.put ("foo", "bar"); aLinkedMap.put ("foo2", Integer.valueOf (5)); assertTrue (JsonConverter.convertToJson (aLinkedMap) instanceof JsonObject); }
Example #8
Source File: JsonWriterTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testWriteAndReadMap () { final ICommonsMap <String, Object> aMap = new CommonsHashMap <> (); aMap.put ("foo", "bar"); _testWriteAndRead (aMap); final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap <> (); aTreeMap.put ("foo", "bar"); aTreeMap.put ("foo2", Integer.valueOf (5)); _testWriteAndRead (aTreeMap); final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> (); aLinkedMap.put ("foo", "bar"); aLinkedMap.put ("foo2", Integer.valueOf (5)); _testWriteAndRead (aLinkedMap); }
Example #9
Source File: JsonWriterTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testMap () { final ICommonsMap <String, Object> aMap = new CommonsHashMap <> (); aMap.put ("foo", "bar"); assertEquals ("{\"foo\":\"bar\"}", JsonConverter.convertToJson (aMap).getAsJsonString ()); final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap <> (); aTreeMap.put ("foo", "bar"); aTreeMap.put ("foo2", Integer.valueOf (5)); assertEquals ("{\"foo\":\"bar\",\"foo2\":5}", JsonConverter.convertToJson (aTreeMap).getAsJsonString ()); final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> (); aLinkedMap.put ("foo", "bar"); aLinkedMap.put ("foo2", Integer.valueOf (5)); assertEquals ("{\"foo\":\"bar\",\"foo2\":5}", JsonConverter.convertToJson (aLinkedMap).getAsJsonString ()); assertEquals ("{foo:\"bar\",foo2:5}", JsonConverter.convertToJson (aLinkedMap).getAsJsonString (new JsonWriterSettings ().setQuoteNames (false))); }
Example #10
Source File: XMLMapHandlerTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testReadBuildInfo () { final ICommonsMap <String, String> aMap = new CommonsHashMap <> (); final IReadableResource aRes = new ClassPathResource ("xml/buildinfo.xml"); assertTrue (XMLMapHandler.readMap (aRes, aMap).isSuccess ()); assertNull (XMLMapHandler.readMap (new ClassPathResource ("test1.txt"))); assertTrue (aMap.containsKey ("buildinfo.version")); assertEquals ("1", aMap.get ("buildinfo.version")); assertTrue (XMLMapHandler.readMap (aRes).containsKey ("buildinfo.version")); assertEquals ("1", XMLMapHandler.readMap (aRes).get ("buildinfo.version")); assertTrue (XMLMapHandler.writeMap (aMap, new ByteArrayOutputStreamProvider ()).isSuccess ()); assertTrue (XMLMapHandler.writeMap (aMap, new NonBlockingByteArrayOutputStream ()).isSuccess ()); }
Example #11
Source File: Schematron2XSLTMojoFuncTest.java From ph-schematron with Apache License 2.0 | 6 votes |
@Test public void testMavenPlugin () throws MojoExecutionException, MojoFailureException { expect (project.getBasedir ()).andReturn (new File (".")).anyTimes (); replay (project); // Note: default values are not used here OUT.setSchematronDirectory (new File ("src/test/resources/schematron")); OUT.setSchematronPattern ("**/*.sch"); OUT.setXsltDirectory (new File ("target/test/schematron-via-maven-plugin")); OUT.setXsltExtension (".xslt"); final ICommonsMap <String, String> aParams = new CommonsHashMap <> (); aParams.put ("allow-foreign", "true"); OUT.setParameters (aParams); OUT.execute (); verify (project); }
Example #12
Source File: MultiConfigurationValueProviderTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final MultiConfigurationValueProvider aMCSVP = new MultiConfigurationValueProvider (); // Lower priority final ICommonsMap <String, String> aMap1 = new CommonsHashMap <> (); aMap1.put ("key1", "value1"); aMap1.put ("key2", "value2"); aMCSVP.addConfigurationSource (new ConfigurationSourceFunction (110, aMap1::get)); // Higher priority - should be returned final ICommonsMap <String, String> aMap2 = new CommonsHashMap <> (); aMap2.put ("key1", "value2"); aMap2.put ("key3", "value3"); aMCSVP.addConfigurationSource (new ConfigurationSourceFunction (111, aMap2::get)); // Resolve assertEquals ("value2", aMCSVP.getConfigurationValue ("key1").getValue ()); assertEquals ("value2", aMCSVP.getConfigurationValue ("key2").getValue ()); assertEquals ("value3", aMCSVP.getConfigurationValue ("key3").getValue ()); assertNull (aMCSVP.getConfigurationValue ("key4")); }
Example #13
Source File: WSClientConfigTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final WSClientConfig aCfg = new WSClientConfig (URLHelper.getAsURL ("http://www.example.org")); final ICommonsMap <String, Object> aMap = new CommonsHashMap <> (); final BindingProvider aBP = new MockBP (aMap); aCfg.applyWSSettingsToBindingProvider (aBP); assertEquals (5, aMap.size ()); assertEquals ("http://www.example.org", aMap.get (BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); // 2 versions assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_CONNECTION_TIMEOUT_MS), aMap.get ("com.sun.xml.ws.connect.timeout")); assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_CONNECTION_TIMEOUT_MS), aMap.get ("com.sun.xml.internal.ws.connect.timeout")); // 2 versions assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_REQUEST_TIMEOUT_MS), aMap.get ("com.sun.xml.ws.request.timeout")); assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_REQUEST_TIMEOUT_MS), aMap.get ("com.sun.xml.internal.ws.request.timeout")); }
Example #14
Source File: EqualsHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testComplex () { final ICommonsMap <ICommonsList <String>, ICommonsSet <String>> aMap = new CommonsHashMap <> (); aMap.put (new CommonsArrayList <> ("a", "b", "c"), new CommonsHashSet <> ("a", "b", "c")); aMap.put (new CommonsArrayList <> ("a", "b", "d"), new CommonsHashSet <> ("a", "b", "d")); assertTrue (EqualsHelper.equalsCollection (aMap, CollectionHelper.newMap (aMap))); assertFalse (EqualsHelper.equalsCollection (aMap, ArrayHelper.newArray ("a", "b", "c", "d"))); assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsArrayList <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashSet <> ("a", "b", "c"))); final ICommonsMap <String, String> aMap1a = new CommonsHashMap <> (); aMap1a.put ("a", "b"); assertFalse (EqualsHelper.equalsCollection (aMap, aMap1a)); final ICommonsMap <ICommonsList <String>, String> aMap2 = new CommonsHashMap <> (); aMap2.put (new CommonsArrayList <> ("a", "b", "c"), "d"); aMap2.put (new CommonsArrayList <> ("a", "b", "d"), "e"); aMap2.put (new CommonsArrayList <> ("a", "b", "e"), null); aMap2.put (null, "g"); assertFalse (EqualsHelper.equalsCollection (aMap, aMap2)); assertFalse (EqualsHelper.equalsCollection (aMap2, aMap)); final ICommonsMap <String, ICommonsList <String>> aMap3 = new CommonsHashMap <> (); aMap3.put ("d", new CommonsArrayList <> ("a", "b", "c")); aMap3.put ("e", new CommonsArrayList <> ("a", "b", "d")); aMap3.put (null, new CommonsArrayList <> ("a", "b", "e")); aMap3.put ("g", null); assertFalse (EqualsHelper.equalsCollection (aMap, aMap3)); assertFalse (EqualsHelper.equalsCollection (aMap3, aMap)); }
Example #15
Source File: SchematronValidationMojo.java From ph-schematron with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy @VisibleForTesting ICommonsMap <String, String> getParameters () { return new CommonsHashMap <> (m_aCustomParameters); }
Example #16
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <KEYTYPE, VALUETYPE> CommonsHashMap <KEYTYPE, VALUETYPE> newMap (@Nullable final Collection <? extends KEYTYPE> aKeys, @Nullable final Collection <? extends VALUETYPE> aValues) { final int nKeys = getSize (aKeys); final int nValues = getSize (aValues); // Check for identical size if (nKeys != nValues) throw new IllegalArgumentException ("The passed arrays have different length (" + nKeys + " keys and " + nValues + " values)!"); // Are both empty? if (nKeys == 0) return newMap (0); final CommonsHashMap <KEYTYPE, VALUETYPE> ret = newMap (nKeys); final Iterator <? extends KEYTYPE> itk = aKeys.iterator (); final Iterator <? extends VALUETYPE> itv = aValues.iterator (); while (itk.hasNext ()) ret.put (itk.next (), itv.next ()); return ret; }
Example #17
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <KEYTYPE, VALUETYPE> CommonsHashMap <KEYTYPE, VALUETYPE> newMap (@Nullable final Map <? extends KEYTYPE, ? extends VALUETYPE> aMap) { if (isEmpty (aMap)) return newMap (0); return new CommonsHashMap <> (aMap); }
Example #18
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <KEYTYPE, VALUETYPE> CommonsHashMap <KEYTYPE, VALUETYPE> newMap (@Nullable final Map <? extends KEYTYPE, ? extends VALUETYPE> [] aMaps) { if (aMaps == null || aMaps.length == 0) return newMap (0); final CommonsHashMap <KEYTYPE, VALUETYPE> ret = newMap (); for (final Map <? extends KEYTYPE, ? extends VALUETYPE> aMap : aMaps) ret.putAll (aMap); return ret; }
Example #19
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <KEYTYPE, VALUETYPE> CommonsHashMap <KEYTYPE, VALUETYPE> newMap (@Nullable final Collection <? extends Map.Entry <KEYTYPE, VALUETYPE>> aCollection) { if (isEmpty (aCollection)) return newMap (0); final CommonsHashMap <KEYTYPE, VALUETYPE> ret = newMap (aCollection.size ()); ret.putAll (aCollection); return ret; }
Example #20
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <KEYTYPE, VALUETYPE> CommonsHashMap <KEYTYPE, VALUETYPE> newMap (@Nullable final Iterable <? extends Map.Entry <KEYTYPE, VALUETYPE>> aCollection) { if (isEmpty (aCollection)) return newMap (0); final CommonsHashMap <KEYTYPE, VALUETYPE> ret = newMap (); ret.putAll (aCollection); return ret; }
Example #21
Source File: SystemProperties.java From ph-commons with Apache License 2.0 | 5 votes |
/** * @return A map with all system properties where the key is the system * property name and the value is the system property value. */ @Nonnull @ReturnsMutableCopy public static ICommonsMap <String, String> getAllProperties () { final Properties aProperties = IPrivilegedAction.systemGetProperties ().invokeSafe (); if (aProperties == null) return new CommonsHashMap <> (); return PropertiesHelper.getAsStringMap (aProperties); }
Example #22
Source File: Schematron2XSLTMojo.java From ph-schematron with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy @VisibleForTesting ICommonsMap <String, String> getParameters () { return new CommonsHashMap <> (m_aCustomParameters); }
Example #23
Source File: PSXPathBoundSchema.java From ph-schematron with Apache License 2.0 | 5 votes |
@Nullable private ICommonsMap <String, PSXPathBoundDiagnostic> _createBoundDiagnostics (@Nonnull final XPath aXPathContext, @Nonnull final PSXPathVariables aGlobalVariables) { final ICommonsMap <String, PSXPathBoundDiagnostic> ret = new CommonsHashMap <> (); boolean bHasAnyError = false; final PSSchema aSchema = getOriginalSchema (); if (aSchema.hasDiagnostics ()) { // For all contained diagnostic elements for (final PSDiagnostic aDiagnostic : aSchema.getDiagnostics ().getAllDiagnostics ()) { final ICommonsList <PSXPathBoundElement> aBoundElements = _createBoundElements (aDiagnostic, aXPathContext, aGlobalVariables); if (aBoundElements == null) { // error already emitted bHasAnyError = true; } else { final PSXPathBoundDiagnostic aBoundDiagnostic = new PSXPathBoundDiagnostic (aDiagnostic, aBoundElements); if (ret.put (aDiagnostic.getID (), aBoundDiagnostic) != null) { error (aDiagnostic, "A diagnostic element with ID '" + aDiagnostic.getID () + "' was overwritten!"); bHasAnyError = true; } } } } if (bHasAnyError) return null; return ret; }
Example #24
Source File: CollectionHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testIsEmpty () { assertTrue (isEmpty ((ICommonsList <?>) null)); assertTrue (isEmpty ((Map <?, ?>) null)); assertTrue (isEmpty (new CommonsVector <> ())); assertTrue (isEmpty (new CommonsHashMap <> ())); assertFalse (isEmpty (newList ("d", "c", "b", "a"))); assertTrue (isEmpty ((Iterable <?>) new NonBlockingStack <> ())); }
Example #25
Source File: FontKerningFuncTest.java From ph-commons with Apache License 2.0 | 5 votes |
/** * @param aIS * The data for the TTF font. * @throws IOException * If the font could not be read. */ public Kerning (@Nonnull @WillClose final InputStream aIS) throws IOException { ValueEnforcer.notNull (aIS, "IS"); try (final InputStream aDIS = aIS) { _readTableDirectory (aDIS); if (m_nHeadOffset == -1) throw new IOException ("HEAD table not found."); if (m_nKernOffset == -1) { LOGGER.info ("No kerning information present!"); m_aKerning = Collections.emptyMap (); return; } m_aKerning = new CommonsHashMap <> (2048); if (m_nHeadOffset < m_nKernOffset) { _readHEAD (aDIS); _readKERN (aDIS); } else { _readKERN (aDIS); _readHEAD (aDIS); } } }
Example #26
Source File: FontKerningFuncTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testKerning () throws IOException { if (EOperatingSystem.getCurrentOS ().isWindowsBased ()) { // required to get graphics up and running... GraphicsEnvironment.getLocalGraphicsEnvironment (); final int nFontSize = 25; final ICommonsMap <TextAttribute, Object> aTextAttributes = new CommonsHashMap <> (); aTextAttributes.put (TextAttribute.FAMILY, "Arial"); aTextAttributes.put (TextAttribute.SIZE, Float.valueOf (nFontSize)); final Font aFont = Font.getFont (aTextAttributes); final char [] aChars = "T,".toCharArray (); final GlyphVector aGlyphVector = aFont.layoutGlyphVector (new FontRenderContext (new AffineTransform (), false, true), aChars, 0, aChars.length, Font.LAYOUT_LEFT_TO_RIGHT); final int tCode = aGlyphVector.getGlyphCode (0); final int commaCode = aGlyphVector.getGlyphCode (1); final Kerning aKerning = new Kerning (new FileInputStream (System.getenv ("windir") + "/fonts/ARIAL.TTF")); LOGGER.info (Float.toString (aKerning.getValue (tCode, commaCode, nFontSize))); } else LOGGER.warn ("Works only on Windows!"); }
Example #27
Source File: TextHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testCreateMultilingualTextFromMap () { final ICommonsMap <String, String> aParamNames = new CommonsHashMap <> (); IMultilingualText aMLT = TextHelper.createMultilingualTextFromMap (aParamNames); assertEquals (0, aMLT.texts ().size ()); aParamNames.put ("de", "x"); aParamNames.put ("en", "y"); aMLT = TextHelper.createMultilingualTextFromMap (aParamNames); assertEquals (2, aMLT.texts ().size ()); assertEquals ("x", aMLT.getText (L_DE)); assertEquals ("y", aMLT.getText (L_EN)); }
Example #28
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <KEYTYPE, VALUETYPE> CommonsHashMap <KEYTYPE, VALUETYPE> newMap (@Nullable final Map <KEYTYPE, VALUETYPE> aMap, @Nonnull final Predicate <? super Map.Entry <? extends KEYTYPE, ? extends VALUETYPE>> aFilter) { if (isEmpty (aMap)) return newMap (0); final CommonsHashMap <KEYTYPE, VALUETYPE> ret = newMap (aMap.size ()); ret.putAll (aMap, aFilter); return ret; }
Example #29
Source File: CollectionHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testGetSize_Map () { assertEquals (0, getSize ((Map <?, ?>) null)); assertEquals (0, getSize (new CommonsHashMap <BigDecimal, String> ())); assertEquals (1, getSize (newMap ("key", "value"))); }
Example #30
Source File: CollectionHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testIsEmpty_Map () { assertTrue (isEmpty ((Map <?, ?>) null)); assertTrue (isEmpty (new CommonsHashMap <String, Double> ())); assertFalse (isEmpty (newMap ("any", "value"))); }