public class CollectionUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static TypeMap |
collectionClassesByNames |
static TypeMap |
collectionInterfacesByNames |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEqual(java.lang.Object value,
java.lang.Object otherValue)
A comprehensive isEqual method that handles nulls and arrays safely.
|
static boolean |
arraysAreEqual(java.lang.Object value,
java.lang.Object otherValue)
Returns true if the objects are array instances and each of their elements compares
via equals as well.
|
static <T> java.util.Set<T> |
asSet(T[] items)
Returns the items as a populated set.
|
static java.lang.Class |
getCollectionTypeFor(java.lang.String shortName)
Returns the collection type if we recognize it by its short name.
|
static <K,V> java.util.Map<V,K> |
invertedMapFrom(java.util.Map<K,V> source)
Returns a map based on the source but with the key & values swapped.
|
static boolean |
isCollectionType(java.lang.Class clazzType,
boolean includeInterfaces)
Return whether we can identify the typeName as a java.util collection class
or interface as specified.
|
static boolean |
isCollectionType(java.lang.String typeName,
boolean includeInterfaces)
Return whether we can identify the typeName as a java.util collection class
or interface as specified.
|
static <K,V> java.util.Map<K,V> |
mapFrom(K[] keys,
V[] values)
Creates and returns a map populated with the keyValuesSets where
the value held by the tuples are they key and value in that order.
|
static boolean |
valuesAreTransitivelyEqual(java.lang.Object[] thisArray,
java.lang.Object[] thatArray)
Returns whether the arrays are equal by examining each of their elements, even if they are
arrays themselves.
|
public static final TypeMap collectionInterfacesByNames
public static final TypeMap collectionClassesByNames
public static java.lang.Class getCollectionTypeFor(java.lang.String shortName)
shortName - Stringpublic static boolean isCollectionType(java.lang.String typeName,
boolean includeInterfaces)
typeName - StringincludeInterfaces - booleanpublic static boolean isCollectionType(java.lang.Class clazzType,
boolean includeInterfaces)
clazzType - ClassincludeInterfaces - booleanpublic static <T> java.util.Set<T> asSet(T[] items)
items - Object[]public static <K,V> java.util.Map<K,V> mapFrom(K[] keys,
V[] values)
keys - K[]values - V[]public static <K,V> java.util.Map<V,K> invertedMapFrom(java.util.Map<K,V> source)
source - Mappublic static final boolean arraysAreEqual(java.lang.Object value,
java.lang.Object otherValue)
value - ObjectotherValue - Objectpublic static final boolean valuesAreTransitivelyEqual(java.lang.Object[] thisArray,
java.lang.Object[] thatArray)
thisArray - Object[]thatArray - Object[]public static final boolean areEqual(java.lang.Object value,
java.lang.Object otherValue)
value - ObjectotherValue - Object