Class CollectionUtil
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.util.CollectionUtil
-
public final class CollectionUtil extends Object
Utility class for working with collections and arrays.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]
addFirst(T[] array, T element, Class<T> clazz)
Adds the element argument to the start of the supplied array argument, but if the array is null then return the element as a new array with just that item in it.static <E> List<E>
asList(E... elements)
Converts varargs to aList
.static <K,V>
LinkedHashMap<K,V>asMap(Object... elements)
Converts varargs to aMap
where the elements are key/value pairs.static <E> LinkedHashSet<E>
asSet(E... elements)
Converts varargs to aSet
.static <E> LinkedHashSet<E>
asSet(Collection<E> elements)
ConvertsCollection
to aSet
.static <K,V>
ConcurrentHashMap<K,V>clone(ConcurrentHashMap<K,V> map)
Clones a givenConcurrentHashMap
by creating a new map and copying all entries from the original map.
-
-
-
Method Detail
-
asList
public static <E> List<E> asList(E... elements)
Converts varargs to aList
.
-
asSet
public static <E> LinkedHashSet<E> asSet(E... elements)
Converts varargs to aSet
.
-
asSet
public static <E> LinkedHashSet<E> asSet(Collection<E> elements)
ConvertsCollection
to aSet
.
-
asMap
public static <K,V> LinkedHashMap<K,V> asMap(Object... elements)
Converts varargs to aMap
where the elements are key/value pairs.
-
clone
public static <K,V> ConcurrentHashMap<K,V> clone(ConcurrentHashMap<K,V> map)
Clones a givenConcurrentHashMap
by creating a new map and copying all entries from the original map. If the value of an entry is aSet
or anArrayList
, a deep copy of the value is created. Otherwise, the value is copied as is.
-
addFirst
public static <T> T[] addFirst(T[] array, T element, Class<T> clazz)
Adds the element argument to the start of the supplied array argument, but if the array is null then return the element as a new array with just that item in it.
-
-