|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.collection.CollectionUtils
public class CollectionUtils
| Nested Class Summary | |
|---|---|
static interface |
CollectionUtils.ElementConverter<FROM,TO>
Used to convert a collection element. |
static class |
CollectionUtils.IdentityElementConverter<T>
Does not change the type of the element and the value of the element being converted. |
| Constructor Summary | |
|---|---|
CollectionUtils()
|
|
| Method Summary | ||
|---|---|---|
static void |
addAll(Collection<Integer> integerCollection,
int[] intArray)
Adds an array of integer values to a collection of Integer |
|
static void |
addAll(Collection<Long> longCollection,
long[] intArray)
Adds an array of long values to a collection of Long |
|
static
|
containsObjectIdentity(Collection<E> collection,
Object object)
Returns true if the given Collection contains the given object. |
|
static boolean |
equals(Iterable<?> collection1,
Iterable<?> collection2)
Returns true if the elements of the two given Collections are equal and have the same order |
|
static boolean |
equalsUnordered(Collection<?> collection1,
Collection<?> collection2)
Tests, if the two collection have the same elements. |
|
static
|
hashCode(Collection<E> collection)
Calculates the hash code for a given collection including the order of elements |
|
static
|
hashCodeUnordered(Collection<E> collection)
Calculates the hash code for a given collection not including the order of elements. |
|
static
|
indexOfObjectIdentity(Collection<E> collection,
Object object)
Returns the index position of the first occurring object within the Collection. |
|
static
|
lastIndexOfObjectIdentity(Collection<E> collection,
Object object)
Returns the index position of the last occurring object within the Collection. |
|
static void |
printCollection(Collection<?> collection)
Prints the collection values to the system out. |
|
static double |
sumOfCollectionDouble(Collection<Double> collectionDouble)
Returns the sum of the values within an Double Collection. |
|
static int |
sumOfCollectionInteger(Collection<Integer> collectionInteger)
Returns the sum of the values within an Integer Collection. |
|
static
|
toArray(Collection<E> collection,
Class<? extends E> clazz)
Converts a given Collection into a typed array |
|
static int[] |
toArrayInt(Collection<Integer> integerList)
Returns the values of a Integer collection as array. |
|
static
|
transformCollection(Collection<FROM> collectionFrom,
ListUtils.ElementTransformer<FROM,TO> elementTransformer)
Converts a given Collection into another Collection with other element types using an
ListUtils.ElementTransformer. |
|
static
|
transformCollectionExcludingNullElements(Collection<FROM> collectionFrom,
ListUtils.ElementTransformer<FROM,TO> elementTransformer)
Converts a given Collection into another Collection with other element types, whereby all elements which
convert to null will not be inserted into the target Collection. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CollectionUtils()
| Method Detail |
|---|
public static int sumOfCollectionInteger(Collection<Integer> collectionInteger)
Integer Collection.
collectionInteger -
public static double sumOfCollectionDouble(Collection<Double> collectionDouble)
Double Collection.
collectionDouble -
public static void printCollection(Collection<?> collection)
collection -
public static void addAll(Collection<Integer> integerCollection,
int[] intArray)
integerCollection - intArray -
public static void addAll(Collection<Long> longCollection,
long[] intArray)
longCollection - intArray - public static int[] toArrayInt(Collection<Integer> integerList)
integerList -
public static <E> E[] toArray(Collection<E> collection,
Class<? extends E> clazz)
Collection into a typed array
collection - clazz -
public static boolean equalsUnordered(Collection<?> collection1,
Collection<?> collection2)
collection1 - collection2 -
public static boolean equals(Iterable<?> collection1,
Iterable<?> collection2)
Collections are equal and have the same order
collection1 - collection2 -
public static <TO,FROM> Collection<TO> transformCollection(Collection<FROM> collectionFrom,
ListUtils.ElementTransformer<FROM,TO> elementTransformer)
Collection into another Collection with other element types using an
ListUtils.ElementTransformer.
collectionFrom - elementTransformer -
ListUtils.ElementTransformer
public static <TO,FROM> Collection<TO> transformCollectionExcludingNullElements(Collection<FROM> collectionFrom,
ListUtils.ElementTransformer<FROM,TO> elementTransformer)
Collection into another Collection with other element types, whereby all elements which
convert to null will not be inserted into the target Collection.
collectionFrom - elementTransformer -
ListUtils.ElementTransformer
public static <E> boolean containsObjectIdentity(Collection<E> collection,
Object object)
Collection contains the given object. Contains uses the "object == element" instead of the
"equals" method to determine the object identity.
collection - object -
public static <E> int indexOfObjectIdentity(Collection<E> collection,
Object object)
Collection. Comparisons uses the
"object == element" instead of the "equals" method to determine the object identity.
collection - object -
public static <E> int lastIndexOfObjectIdentity(Collection<E> collection,
Object object)
Collection. Comparisons uses the
"object == element" instead of the "equals" method to determine the object identity.
collection - object -
public static <E> int hashCode(Collection<E> collection)
collection -
public static <E> int hashCodeUnordered(Collection<E> collection)
Set
implementations e.g.
collection -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||