public final class CollectionUtil
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
static TypeMap |
COLLECTION_CLASSES_BY_NAMES |
|
static TypeMap |
COLLECTION_INTERFACES_BY_NAMES |
Modifier and Type | Method | Description |
---|---|---|
static <T> int |
addWithoutDuplicates(java.util.Collection<T> source,
java.util.Collection<T> target) |
Add elements from the source to the target as long as they don't already
exist there.
|
static <T> T[] |
addWithoutDuplicates(T[] values,
T newValue) |
Deprecated.
|
static <T> T[] |
addWithoutDuplicates(T[] values,
T[] newValues) |
Deprecated.
|
static boolean |
areEqual(java.lang.Object value,
java.lang.Object otherValue) |
Deprecated.
Objects.deepEquals(Object, Object) |
static <T> boolean |
areSemanticEquals(T[] a,
T[] b) |
Deprecated.
Arrays.deepEquals(Object[], Object[]) |
static boolean |
arraysAreEqual(java.lang.Object value,
java.lang.Object otherValue) |
Deprecated.
Objects.deepEquals(Object, Object) |
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 boolean |
isEmpty(java.lang.Object[] items) |
Returns whether the items array is null or has zero length.
|
static boolean |
isNotEmpty(java.lang.Object[] items) |
Returns whether the items array is non-null and has at least one entry.
|
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 <T> java.util.List<T> |
toList(java.util.Iterator<T> it) |
Consumes all the elements of the iterator and
returns a list containing them.
|
static boolean |
valuesAreTransitivelyEqual(java.lang.Object[] thisArray,
java.lang.Object[] thatArray) |
Deprecated.
Arrays.deepEquals(Object[], Object[]) |
public static final TypeMap COLLECTION_INTERFACES_BY_NAMES
public static final TypeMap COLLECTION_CLASSES_BY_NAMES
public static <T> int addWithoutDuplicates(java.util.Collection<T> source, java.util.Collection<T> target)
source
- target
- 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 <T> java.util.List<T> toList(java.util.Iterator<T> it)
it
- An iterator@Deprecated public static boolean arraysAreEqual(java.lang.Object value, java.lang.Object otherValue)
Objects.deepEquals(Object, Object)
value
- ObjectotherValue
- Object@Deprecated public static boolean valuesAreTransitivelyEqual(java.lang.Object[] thisArray, java.lang.Object[] thatArray)
Arrays.deepEquals(Object[], Object[])
thisArray
- Object[]thatArray
- Object[]@Deprecated public static boolean areEqual(java.lang.Object value, java.lang.Object otherValue)
Objects.deepEquals(Object, Object)
value
- ObjectotherValue
- Objectpublic static boolean isEmpty(java.lang.Object[] items)
items
- public static boolean isNotEmpty(java.lang.Object[] items)
items
- @Deprecated public static <T> boolean areSemanticEquals(T[] a, T[] b)
Arrays.deepEquals(Object[], Object[])
T
- a
- b
- @Deprecated public static <T> T[] addWithoutDuplicates(T[] values, T newValue)
T
- values
- newValue
- @Deprecated public static <T> T[] addWithoutDuplicates(T[] values, T[] newValues)
T
- values
- newValues
- Copyright © 2002–2018 PMD. All rights reserved.