|
||||||||||
| 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.CollectionConverter<FROM,TO>
Transformer interface for transforming whole Collections into a single object |
static class |
CollectionUtils.CollectionTransformerToString<FROM>
CollectionUtils.CollectionConverter which produces a String from a Collection |
| Constructor Summary | |
|---|---|
CollectionUtils()
|
|
| Method Summary | ||
|---|---|---|
static
|
adapter(Collection<FROM> collection,
ElementBidirectionalConverter<FROM,TO> elementBidirectionalConverter)
Returns a new CollectionToCollectionAdapter instance |
|
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
|
composite(Collection<Collection<E>> collectionOfCollections)
Returns a new CollectionComposite instance for the given Collections |
|
static
|
composite(Collection<E>... collections)
Returns a new CollectionComposite instance for the given Collections |
|
static
|
containsObjectIdentity(Collection<E> collection,
Object object)
Returns true if the given Collection contains the given object. |
|
static
|
convert(Collection<FROM> collection,
CollectionUtils.CollectionConverter<FROM,TO> collectionConverter)
Converts a given Collection instance from one generic type into a single value using a CollectionUtils.CollectionConverter |
|
static
|
convertCollection(Collection<FROM> collectionFrom,
ElementConverter<FROM,TO> elementConverter)
Converts a given Collection into another Collection with other element types using an
ElementConverter. |
|
static
|
convertCollectionExcludingNullElements(Collection<FROM> collectionFrom,
ElementConverter<FROM,TO> elementConverter)
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. |
|
static
|
copyIntoCollectionFrom(Collection<E> collection,
Iterable<E> iterable)
Copies all elements from the given Iterable into the given Collection |
|
static
|
copyIntoCollectionFrom(Collection<E> collection,
Iterable<E> iterable,
int maxNumberOfElements)
Copies all elements from the given Iterable into the given Collection |
|
static
|
copyIntoCollectionFrom(Collection<E> collection,
Iterator<E> iterator)
Copies all elements from the given Iterator into the given Collection This traverses the Iterator |
|
static
|
copyIntoCollectionFrom(Collection<E> collection,
Iterator<E> iterator,
int maxNumberOfElements)
Copies all elements from the given Iterator into the given Collection.This traverses the Iterator
only as far as necessary. |
|
static
|
drainTo(Iterable<E> iterable,
Collection<E> collection)
Drains the elements of the given Iterable to the given Collection |
|
static
|
drainTo(Iterable<E> iterable,
Collection<E> collection,
int maxNumberOfElements)
Drains the elements of the given Iterable by the given maximum number of elements to the given Collection. |
|
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
|
locked(Collection<E> collection,
Lock lock)
Returns a view of the given Collection which uses the given Lock to synchronize all of its methods |
|
static
|
lockedByReentrantLock(Collection<E> collection)
Returns a view of the given Collection which uses a new ReentrantLock instance to synchronize all of its
methods |
|
static
|
mergeAll(Collection<E>... collections)
Merges all elements of the given Collection instances into one single Collection instance which keeps the
order of the elements. |
|
static double |
sumOfCollectionDouble(Iterable<Double> doubleIterable)
Returns the sum of the values within an Double Iterable. |
|
static int |
sumOfCollectionInteger(Iterable<Integer> integerIterable)
Returns the sum of the values within an Integer Iterable. |
|
static
|
toArray(Collection<E> collection,
Class<? extends E> clazz)
Converts a given Collection into a typed array |
|
static int[] |
toArrayInt(Collection<Integer> integerCollection)
Returns the values of a Integer Collection as array. |
|
static
|
toMap(Iterable<E> iterable,
ElementConverterElementToMapEntry<E,K,V> elementToMapEntryTransformer)
Transforms a given Iterable into a Map using a LinkedHashMap which keeps the order of the
List. |
|
static
|
toString(Collection<E> collection,
ElementConverter<E,String> elementConverter,
com.google.common.base.Joiner joiner)
|
|
static
|
toString(Collection<E> collection,
com.google.common.base.Joiner joiner)
|
|
static
|
toString(Collection<E> collection,
com.google.common.base.Joiner joiner,
String prefix,
String suffix)
|
|
static String |
toString(Iterable<?> iterable)
Returns a String representation of the given Iterable using String.valueOf(boolean) |
|
| 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 void addAll(Collection<Integer> integerCollection,
int[] intArray)
integerCollection - intArray -
public static void addAll(Collection<Long> longCollection,
long[] intArray)
longCollection - intArray -
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 <FROM,TO> TO convert(Collection<FROM> collection,
CollectionUtils.CollectionConverter<FROM,TO> collectionConverter)
Collection instance from one generic type into a single value using a CollectionUtils.CollectionConverter
collection - collectionConverter - CollectionUtils.CollectionConverter
public static <TO,FROM> Collection<TO> convertCollection(Collection<FROM> collectionFrom,
ElementConverter<FROM,TO> elementConverter)
Collection into another Collection with other element types using an
ElementConverter.
collectionFrom - elementConverter -
ElementConverter
public static <TO,FROM> Collection<TO> convertCollectionExcludingNullElements(Collection<FROM> collectionFrom,
ElementConverter<FROM,TO> elementConverter)
Collection into another Collection with other element types, whereby all elements which
convert to null will not be inserted into the target Collection.
collectionFrom - elementConverter -
ElementConverter
public static boolean equals(Iterable<?> collection1,
Iterable<?> collection2)
Collections are equal and have the same order
collection1 - collection2 -
public static boolean equalsUnordered(Collection<?> collection1,
Collection<?> collection2)
collection1 - collection2 -
public static <E> int hashCode(Collection<E> collection)
collection -
public static <E> int hashCodeUnordered(Collection<E> collection)
Set
implementations e.g.
collection -
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> Collection<E> mergeAll(Collection<E>... collections)
Collection instances into one single Collection instance which keeps the
order of the elements.
E - collections -
public static String toString(Iterable<?> iterable)
String representation of the given Iterable using String.valueOf(boolean)
iterable -
public static <E> String toString(Collection<E> collection,
com.google.common.base.Joiner joiner,
String prefix,
String suffix)
collection - joiner - Joinerprefix - suffix -
public static <E> String toString(Collection<E> collection,
com.google.common.base.Joiner joiner)
collection - joiner - Joiner
public static <E> String toString(Collection<E> collection,
ElementConverter<E,String> elementConverter,
com.google.common.base.Joiner joiner)
public static double sumOfCollectionDouble(Iterable<Double> doubleIterable)
Double Iterable.
doubleIterable -
public static int sumOfCollectionInteger(Iterable<Integer> integerIterable)
Integer Iterable.
integerIterable -
public static <E> E[] toArray(Collection<E> collection,
Class<? extends E> clazz)
Collection into a typed array
collection - clazz -
public static int[] toArrayInt(Collection<Integer> integerCollection)
Integer Collection as array.
integerCollection -
public static <K,V,E> Map<K,V> toMap(Iterable<E> iterable,
ElementConverterElementToMapEntry<E,K,V> elementToMapEntryTransformer)
Iterable into a Map using a LinkedHashMap which keeps the order of the
List. Returns an empty Map for a null value as Iterable. Null values within the Iterable will
be excluded from the map, if the respective ElementConverterElementToMapEntry.convert(Object) returns null.
iterable - elementToMapEntryTransformer -
ElementConverterElementToMapEntry
public static <E> Collection<E> locked(Collection<E> collection,
Lock lock)
Collection which uses the given Lock to synchronize all of its methods
collection - lock -
public static <E> Collection<E> lockedByReentrantLock(Collection<E> collection)
Collection which uses a new ReentrantLock instance to synchronize all of its
methods
collection - F@return
public static <E> void drainTo(Iterable<E> iterable,
Collection<E> collection)
Iterable to the given Collection
iterable - collection -
public static <E> void drainTo(Iterable<E> iterable,
Collection<E> collection,
int maxNumberOfElements)
Iterable by the given maximum number of elements to the given Collection.
iterable - collection - maxNumberOfElements -
public static <E> void copyIntoCollectionFrom(Collection<E> collection,
Iterable<E> iterable)
Iterable into the given Collection
collection - iterable -
public static <E> void copyIntoCollectionFrom(Collection<E> collection,
Iterable<E> iterable,
int maxNumberOfElements)
Iterable into the given Collection
collection - iterable - maxNumberOfElements -
public static <E> void copyIntoCollectionFrom(Collection<E> collection,
Iterator<E> iterator)
Iterator into the given Collection Iterator
collection - iterator -
public static <E> void copyIntoCollectionFrom(Collection<E> collection,
Iterator<E> iterator,
int maxNumberOfElements)
Iterator into the given Collection.This traverses the Iterator
only as far as necessary.
collection - iterator - maxNumberOfElements -
public static <FROM,TO> Collection<TO> adapter(Collection<FROM> collection,
ElementBidirectionalConverter<FROM,TO> elementBidirectionalConverter)
CollectionToCollectionAdapter instance
collection - CollectionelementBidirectionalConverter - ElementBidirectionalConverter
CollectionToCollectionAdapter instancepublic static <E> Collection<E> composite(Collection<Collection<E>> collectionOfCollections)
CollectionComposite instance for the given Collections
collectionOfCollections -
public static <E> Collection<E> composite(Collection<E>... collections)
CollectionComposite instance for the given Collections
collections -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||