public final class CollectionExtensions
extends java.lang.Object
CollectionExtensions is an extension class for use with Collection
objects.| Modifier and Type | Method and Description |
|---|---|
static <T> void |
difference(java.util.Collection<T> one,
java.util.Collection<T> other)
Removes all of the first given collection's elements that are also contained in the second
given collection.
|
static <T> int |
hashCode(java.util.Collection<T[]> arrayObjects)
Returns a hash code based on the contents of the collection that contains array objects.
|
static <T> java.util.Collection<T> |
intersection(java.util.Collection<T>... toIntersect)
Intersection of the given collections.
|
static <T> boolean |
isEmpty(java.util.Collection<T> collection)
Checks if the given
Collection is null or empty. |
static <T> boolean |
isEqualCollection(java.util.Collection<T> one,
java.util.Collection<T> other)
Compare the given two
Collection objects in equality. |
static <T> boolean |
isNotEmpty(java.util.Collection<T> collection)
Checks if the given
Collection is not null or empty |
static <T> java.util.Collection<java.util.List<T>> |
partition(java.util.Collection<T> collection,
int size)
Groups the given
Collection to parts from the specified size. |
static <T> java.util.Optional<java.lang.Boolean> |
preconditionOfEqualCollection(java.util.Collection<T> one,
java.util.Collection<T> other)
Checks the given two
Collection objects if there are null and return the appropriate
Optional boolean value |
public static <T> void difference(java.util.Collection<T> one,
java.util.Collection<T> other)
T - the generic typeone - the collection where the element will be removed if any containing elements existsother - collection containing elements to be removed from the first given collectionpublic static <T> int hashCode(java.util.Collection<T[]> arrayObjects)
T - the generic type of the array objectsarrayObjects - the collection that contains array objects whose content-based hash code to
compute@SafeVarargs public static <T> java.util.Collection<T> intersection(java.util.Collection<T>... toIntersect)
Collection.retainAll(Collection) for come to the result.T - the generic typetoIntersect - the to intersectpublic static <T> boolean isEmpty(java.util.Collection<T> collection)
Collection is null or empty.T - the generic typecollection - The collection to checkCollection is null or empty otherwise false.public static <T> boolean isEqualCollection(java.util.Collection<T> one,
java.util.Collection<T> other)
Collection objects in equality.T - the generic type of the elementsone - the oneother - the otherCollection objects are equal otherwise falsepublic static <T> boolean isNotEmpty(java.util.Collection<T> collection)
Collection is not null or emptyT - the generic typecollection - The collection to checkCollection is null or empty otherwise falsepublic static <T> java.util.Collection<java.util.List<T>> partition(java.util.Collection<T> collection,
int size)
Collection to parts from the specified size.T - the generic typecollection - the collectionsize - the sizepublic static <T> java.util.Optional<java.lang.Boolean> preconditionOfEqualCollection(java.util.Collection<T> one,
java.util.Collection<T> other)
Collection objects if there are null and return the appropriate
Optional boolean valueT - the generic type of the elementsone - the oneother - the otherOptional boolean if value is true both are null, if value is false given
two Collection objects are not equal otherwise the Optional is empty