Java Code Examples for com.helger.commons.collection.CollectionHelper#newMap()

The following examples show how to use com.helger.commons.collection.CollectionHelper#newMap() . 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: MultilingualTextMicroTypeConverterRegistrarTest.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadonlyMultiLingualText ()
{
  final ReadOnlyMultilingualText aMLT = new ReadOnlyMultilingualText (CollectionHelper.newMap (new Locale [] { Locale.GERMAN,
                                                                                                               Locale.CHINA },
                                                                                               new String [] { "Cumberlandstraße",
                                                                                                               "Whatspever" }));

  final IMicroElement aElement = MicroTypeConverter.convertToMicroElement (aMLT, "mtext");
  assertNotNull (aElement);

  final ReadOnlyMultilingualText aMLT2 = MicroTypeConverter.convertToNative (aElement,
                                                                             ReadOnlyMultilingualText.class);
  assertEquals (aMLT, aMLT2);
  assertNull (MicroTypeConverter.convertToNative (null, ReadOnlyMultilingualText.class));

  CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aMLT, aMLT2);
}
 
Example 2
Source File: JsonWriterTest.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testComplex ()
{
  final ICommonsList <JsonObject> aObjs = new CommonsArrayList <> ();
  for (final ICommonsMap <String, String> aRow : new CommonsArrayList <> (CollectionHelper.newMap ("key", "value")))
  {
    final JsonObject aObj = new JsonObject ();
    for (final Map.Entry <String, String> aEntry : aRow.entrySet ())
      aObj.add (aEntry.getKey (), aEntry.getValue ());
    aObjs.add (aObj);
  }
  assertEquals ("{\"aa\":[{\"key\":\"value\"}]}", JsonConverter.convertToJson (new JsonObject ().add ("aa", aObjs)).getAsJsonString ());
}
 
Example 3
Source File: CommonsConcurrentHashMapTest.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSwappedKeyValues ()
{
  final ICommonsMap <String, Integer> aMap = CollectionHelper.newMap (new String [] { "a", "b", "c" },
                                                                      new Integer [] { Integer.valueOf (0),
                                                                                       Integer.valueOf (1),
                                                                                       Integer.valueOf (2) });
  final ICommonsMap <Integer, String> aMapSwapped = aMap.getSwappedKeyValues ();
  assertEquals (aMap.size (), aMapSwapped.size ());
  assertEquals (aMap, aMapSwapped.getSwappedKeyValues ());
  assertNotNull (new CommonsConcurrentHashMap <> ().getSwappedKeyValues ());
}
 
Example 4
Source File: CommonsWeakHashMapTest.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSwappedKeyValues ()
{
  final ICommonsMap <String, Integer> aMap = CollectionHelper.newMap (new String [] { "a", "b", "c" },
                                                                      new Integer [] { Integer.valueOf (0),
                                                                                       Integer.valueOf (1),
                                                                                       Integer.valueOf (2) });
  final ICommonsMap <Integer, String> aMapSwapped = aMap.getSwappedKeyValues ();
  assertEquals (aMap.size (), aMapSwapped.size ());
  assertEquals (aMap, aMapSwapped.getSwappedKeyValues ());
  assertNotNull (new CommonsWeakHashMap <> ().getSwappedKeyValues ());
}
 
Example 5
Source File: CommonsHashMapTest.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSwappedKeyValues ()
{
  final ICommonsMap <String, Integer> aMap = CollectionHelper.newMap (new String [] { "a", "b", "c" },
                                                                      new Integer [] { Integer.valueOf (0),
                                                                                       Integer.valueOf (1),
                                                                                       Integer.valueOf (2) });
  final ICommonsMap <Integer, String> aMapSwapped = aMap.getSwappedKeyValues ();
  assertEquals (aMap.size (), aMapSwapped.size ());
  assertEquals (aMap, aMapSwapped.getSwappedKeyValues ());
  assertNotNull (new CommonsHashMap <> ().getSwappedKeyValues ());
}
 
Example 6
Source File: AbstractMultiMapTestCase.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected final ICommonsMap <String, ICommonsList <String>> getMapList1 ()
{
  return CollectionHelper.newMap (getKey1 (), getValueList1 ());
}
 
Example 7
Source File: AbstractMultiMapTestCase.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected final ICommonsMap <String, ICommonsSet <String>> getMapSet1 ()
{
  return CollectionHelper.newMap (getKey1 (), getValueSet1 ());
}
 
Example 8
Source File: AbstractMultiMapTestCase.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected final ICommonsMap <String, ICommonsOrderedSet <String>> getMapSetOrdered1 ()
{
  return CollectionHelper.newMap (getKey1 (), getValueSetOrdered1 ());
}
 
Example 9
Source File: AbstractMultiMapTestCase.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected final ICommonsMap <String, ICommonsNavigableSet <String>> getMapSetNavigable1 ()
{
  return CollectionHelper.newMap (getKey1 (), getValueSetNavigable1 ());
}
 
Example 10
Source File: SingleElementNamespaceContext.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public ICommonsMap <String, String> getPrefixToNamespaceURIMap ()
{
  return CollectionHelper.newMap (m_sPrefix, m_sNamespaceURI);
}
 
Example 11
Source File: MockHasDisplayText.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static MockHasDisplayText createDE_EN (@Nullable final String sDE, @Nullable final String sEN)
{
  return new MockHasDisplayText (CollectionHelper.newMap (new Locale [] { TextHelper.DE, TextHelper.EN },
                                                          new String [] { sDE, sEN }));
}