com.helger.commons.collection.impl.CommonsLinkedHashSet Java Examples
The following examples show how to use
com.helger.commons.collection.impl.CommonsLinkedHashSet.
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: IGetterByIndexTrait.java From ph-commons with Apache License 2.0 | 6 votes |
/** * Get a set of all attribute values with the same name. * * @param nIndex * The index to be accessed. Should be ≥ 0. * @param aDefault * The default value to be returned, if no such attribute is present. * @return <code>aDefault</code> if no such attribute value exists */ @Nullable default ICommonsOrderedSet <String> getAsStringSet (@Nonnegative final int nIndex, @Nullable final ICommonsOrderedSet <String> aDefault) { final Object aValue = getValue (nIndex); if (aValue != null) { if (aValue instanceof String []) { // multiple values passed in the request return new CommonsLinkedHashSet <> ((String []) aValue); } if (aValue instanceof String) { // single value passed in the request return new CommonsLinkedHashSet <> ((String) aValue); } } return aDefault; }
Example #2
Source File: IGetterByKeyTrait.java From ph-commons with Apache License 2.0 | 6 votes |
/** * Get a set of all attribute values with the same name. * * @param aKey * The key to check. May be <code>null</code>. * @param aDefault * The default value to be returned, if no such attribute is present. * @return <code>aDefault</code> if no such attribute value exists */ @Nullable default ICommonsOrderedSet <String> getAsStringSet (@Nullable final KEYTYPE aKey, @Nullable final ICommonsOrderedSet <String> aDefault) { final Object aValue = getValue (aKey); if (aValue != null) { if (aValue instanceof String []) { // multiple values passed in the request return new CommonsLinkedHashSet <> ((String []) aValue); } if (aValue instanceof String) { // single value passed in the request return new CommonsLinkedHashSet <> ((String) aValue); } } return aDefault; }
Example #3
Source File: AttributeContainerAnyTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testWithStringArray () { final AttributeContainerAny <String> aCont = new AttributeContainerAny <> (); aCont.putIn ("a", new String [] { "1", "20" }); // Expected to use the first assertEquals ("1", aCont.getAsString ("a")); assertEquals (1, aCont.getAsInt ("a")); assertEquals (1, aCont.getAsLong ("a")); assertEquals (1, aCont.getAsShort ("a")); assertEquals (1, aCont.getAsByte ("a")); CommonsAssert.assertEquals (1, aCont.getAsDouble ("a")); CommonsAssert.assertEquals (1, aCont.getAsFloat ("a")); assertEquals (BigDecimal.ONE, aCont.getAsBigDecimal ("a")); assertEquals (BigInteger.ONE, aCont.getAsBigInteger ("a")); assertEquals (new CommonsArrayList <> ("1", "20"), aCont.getAsStringList ("a")); assertEquals (new CommonsLinkedHashSet <> ("1", "20"), aCont.getAsStringSet ("a")); }
Example #4
Source File: EqualsHelperTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testSet () { final ICommonsSet <String> aCont = new CommonsHashSet <> ("a", "b", "c"); assertTrue (EqualsHelper.equalsCollection (aCont, aCont)); assertTrue (EqualsHelper.equalsCollection (aCont, CollectionHelper.makeUnmodifiable (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, Collections.synchronizedSet (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsLinkedHashSet <> (aCont))); assertTrue (EqualsHelper.equalsCollection (aCont, new CommonsTreeSet <> (aCont))); assertTrue (EqualsHelper.equalsCollection (new CommonsHashSet <String> (), new CommonsLinkedHashSet <String> ())); assertTrue (EqualsHelper.equalsCollection (new CommonsTreeSet <String> (), new CommonsHashSet <String> ())); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <String> ())); assertFalse (EqualsHelper.equalsCollection (new CommonsHashSet <String> (), aCont)); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsTreeSet <String> ())); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "b"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("A", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "B", "c"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "b", "C"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsHashSet <> ("a", "b", "c", "d"))); assertFalse (EqualsHelper.equalsCollection (aCont, new CommonsArrayList <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aCont, ArrayHelper.newArray ("a", "b", "c"))); }
Example #5
Source File: XMLCharHelper.java From ph-commons with Apache License 2.0 | 6 votes |
@Nullable @ReturnsMutableCopy public static ICommonsOrderedSet <Character> getAllInvalidXMLTextChars (@Nonnull final EXMLSerializeVersion eXMLVersion, @Nullable final char [] aChars, @Nonnegative final int nOfs, @Nonnegative final int nLen) { if (aChars == null || nLen <= 0) return null; final ICommonsOrderedSet <Character> aRes = new CommonsLinkedHashSet <> (); for (int i = 0; i < nLen; ++i) { final char c = aChars[nOfs + i]; if (isInvalidXMLTextChar (eXMLVersion, c)) aRes.add (Character.valueOf (c)); } return aRes; }
Example #6
Source File: XMLCharHelper.java From ph-commons with Apache License 2.0 | 6 votes |
@Nullable @ReturnsMutableCopy public static ICommonsOrderedSet <Character> getAllInvalidXMLCDATAChars (@Nonnull final EXMLSerializeVersion eXMLVersion, @Nullable final char [] aChars, @Nonnegative final int nOfs, @Nonnegative final int nLen) { if (aChars == null || nLen <= 0) return null; final ICommonsOrderedSet <Character> aRes = new CommonsLinkedHashSet <> (); for (int i = 0; i < nLen; ++i) { final char c = aChars[nOfs + i]; if (isInvalidXMLCDATAChar (eXMLVersion, c)) aRes.add (Character.valueOf (c)); } return aRes; }
Example #7
Source File: XMLCharHelper.java From ph-commons with Apache License 2.0 | 6 votes |
@Nullable @ReturnsMutableCopy public static ICommonsOrderedSet <Character> getAllInvalidXMLAttributeValueChars (@Nonnull final EXMLSerializeVersion eXMLVersion, @Nullable final char [] aChars, @Nonnegative final int nOfs, @Nonnegative final int nLen) { if (aChars == null || nLen <= 0) return null; final ICommonsOrderedSet <Character> aRes = new CommonsLinkedHashSet <> (); for (int i = 0; i < nLen; ++i) { final char c = aChars[nOfs + i]; if (isInvalidXMLAttributeValueChar (eXMLVersion, c)) aRes.add (Character.valueOf (c)); } return aRes; }
Example #8
Source File: PrimitiveCollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static CommonsLinkedHashSet <Byte> newPrimitiveOrderedSet (@Nullable final byte... aValues) { final CommonsLinkedHashSet <Byte> ret = new CommonsLinkedHashSet <> (); if (aValues != null) for (final byte aValue : aValues) ret.add (Byte.valueOf (aValue)); return ret; }
Example #9
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testDoubleArray () { final double [] aDoubles = new double [] { 7, 3.14, 47.11 }; assertFalse (TypeConverter.convert (aDoubles, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aDoubles, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aDoubles, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aDoubles, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aDoubles, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aDoubles, String [].class).length); }
Example #10
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testCharArray () { final char [] aChars = new char [] { 'a', 'b', 'c' }; assertFalse (TypeConverter.convert (aChars, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aChars, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aChars, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aChars, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aChars, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aChars, String [].class).length); }
Example #11
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testByteArray () { final byte [] aBytes = new byte [] { 5, 6, 7 }; assertFalse (TypeConverter.convert (aBytes, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aBytes, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aBytes, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aBytes, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aBytes, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aBytes, String [].class).length); }
Example #12
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testBooleanArray () { final boolean [] aBooleans = new boolean [] { true, false, true }; assertFalse (TypeConverter.convert (aBooleans, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aBooleans, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aBooleans, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aBooleans, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aBooleans, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aBooleans, String [].class).length); }
Example #13
Source File: PrimitiveCollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static CommonsLinkedHashSet <Short> newPrimitiveOrderedSet (@Nullable final short... aValues) { final CommonsLinkedHashSet <Short> ret = new CommonsLinkedHashSet <> (); if (aValues != null) for (final short aValue : aValues) ret.add (Short.valueOf (aValue)); return ret; }
Example #14
Source File: PrimitiveCollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static CommonsLinkedHashSet <Long> newPrimitiveOrderedSet (@Nullable final long... aValues) { final CommonsLinkedHashSet <Long> ret = new CommonsLinkedHashSet <> (); if (aValues != null) for (final long aValue : aValues) ret.add (Long.valueOf (aValue)); return ret; }
Example #15
Source File: PrimitiveCollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static CommonsLinkedHashSet <Double> newPrimitiveOrderedSet (@Nullable final double... aValues) { final CommonsLinkedHashSet <Double> ret = new CommonsLinkedHashSet <> (); if (aValues != null) for (final double aValue : aValues) ret.add (Double.valueOf (aValue)); return ret; }
Example #16
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testIntArray () { final int [] aInts = new int [] { 6, 8, 110 }; assertFalse (TypeConverter.convert (aInts, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aInts, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aInts, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aInts, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aInts, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aInts, String [].class).length); }
Example #17
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsLinkedHashSet <ELEMENTTYPE> newOrderedSet (@Nullable final Enumeration <? extends ELEMENTTYPE> aEnum) { final CommonsLinkedHashSet <ELEMENTTYPE> ret = newOrderedSet (); ret.addAll (aEnum); return ret; }
Example #18
Source File: PrimitiveCollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static CommonsLinkedHashSet <Boolean> newPrimitiveOrderedSet (@Nullable final boolean... aValues) { final CommonsLinkedHashSet <Boolean> ret = new CommonsLinkedHashSet <> (); if (aValues != null) for (final boolean aValue : aValues) ret.add (Boolean.valueOf (aValue)); return ret; }
Example #19
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsLinkedHashSet <ELEMENTTYPE> newOrderedSet (@Nullable final IIterableIterator <? extends ELEMENTTYPE> aIter) { if (aIter == null) return newOrderedSet (0); return newOrderedSet (aIter.iterator ()); }
Example #20
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testFloatArray () { final float [] aFloats = new float [] { 5, 1.1f, 12234.5f }; assertFalse (TypeConverter.convert (aFloats, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aFloats, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aFloats, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aFloats, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aFloats, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aFloats, String [].class).length); }
Example #21
Source File: PrimitiveCollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static CommonsLinkedHashSet <Integer> newPrimitiveOrderedSet (@Nullable final int... aValues) { final CommonsLinkedHashSet <Integer> ret = new CommonsLinkedHashSet <> (); if (aValues != null) for (final int aValue : aValues) ret.add (Integer.valueOf (aValue)); return ret; }
Example #22
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsLinkedHashSet <ELEMENTTYPE> newOrderedSet (@Nullable final Collection <? extends ELEMENTTYPE> aCont) { if (isEmpty (aCont)) return newOrderedSet (0); return new CommonsLinkedHashSet <> (aCont); }
Example #23
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsLinkedHashSet <ELEMENTTYPE> newOrderedSet (@Nullable final Iterable <? extends ELEMENTTYPE> aCont) { final CommonsLinkedHashSet <ELEMENTTYPE> ret = newOrderedSet (); ret.addAll (aCont); return ret; }
Example #24
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy @SafeVarargs public static <ELEMENTTYPE> CommonsLinkedHashSet <ELEMENTTYPE> newOrderedSet (@Nullable final ELEMENTTYPE... aValues) { if (ArrayHelper.isEmpty (aValues)) return newOrderedSet (0); final CommonsLinkedHashSet <ELEMENTTYPE> ret = newOrderedSet (aValues.length); Collections.addAll (ret, aValues); return ret; }
Example #25
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsLinkedHashSet <ELEMENTTYPE> newOrderedSet (@Nullable final ELEMENTTYPE aValue) { final CommonsLinkedHashSet <ELEMENTTYPE> ret = newOrderedSet (1); ret.add (aValue); return ret; }
Example #26
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <ELEMENTTYPE> CommonsLinkedHashSet <ELEMENTTYPE> newOrderedSet (@Nullable final Collection <? extends ELEMENTTYPE> aCollection, @Nonnull final Predicate <? super ELEMENTTYPE> aFilter) { if (isEmpty (aCollection)) return newOrderedSet (0); final CommonsLinkedHashSet <ELEMENTTYPE> ret = newOrderedSet (aCollection.size ()); ret.addAll (aCollection, aFilter); return ret; }
Example #27
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <SRCTYPE, DSTTYPE> CommonsLinkedHashSet <DSTTYPE> newOrderedSetMapped (@Nullable final SRCTYPE [] aArray, @Nonnull final Function <? super SRCTYPE, DSTTYPE> aMapper) { if (ArrayHelper.isEmpty (aArray)) return newOrderedSet (0); final CommonsLinkedHashSet <DSTTYPE> ret = newOrderedSet (aArray.length); ret.addAllMapped (aArray, aMapper); return ret; }
Example #28
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static <SRCTYPE, DSTTYPE> CommonsLinkedHashSet <DSTTYPE> newOrderedSetMapped (@Nullable final Collection <? extends SRCTYPE> aCollection, @Nonnull final Function <? super SRCTYPE, DSTTYPE> aMapper) { if (isEmpty (aCollection)) return newOrderedSet (0); final CommonsLinkedHashSet <DSTTYPE> ret = newOrderedSet (aCollection.size ()); ret.addAllMapped (aCollection, aMapper); return ret; }
Example #29
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testLongArray () { final long [] aLongs = new long [] { 10, 111, 1212 }; assertFalse (TypeConverter.convert (aLongs, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aLongs, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aLongs, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aLongs, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aLongs, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aLongs, String [].class).length); }
Example #30
Source File: TypeConverterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testShortArray () { final short [] aShorts = new short [] { 4, 5, 4 }; assertFalse (TypeConverter.convert (aShorts, List.class).isEmpty ()); assertFalse (TypeConverter.convert (aShorts, CommonsArrayList.class).isEmpty ()); assertFalse (TypeConverter.convert (aShorts, Set.class).isEmpty ()); assertFalse (TypeConverter.convert (aShorts, CommonsHashSet.class).isEmpty ()); assertFalse (TypeConverter.convert (aShorts, CommonsLinkedHashSet.class).isEmpty ()); assertEquals (3, TypeConverter.convert (aShorts, String [].class).length); }