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 Details

    • asList

      public static <E> List<E> asList(E... elements)
      Converts varargs to a List.
    • asSet

      public static <E> LinkedHashSet<E> asSet(E... elements)
      Converts varargs to a Set.
    • asSet

      public static <E> LinkedHashSet<E> asSet(Collection<E> elements)
      Converts Collection to a Set.
    • asMap

      public static <K, V> LinkedHashMap<K,V> asMap(Object... elements)
      Converts varargs to a Map where the elements are key/value pairs.
    • clone

      public static <K, V> ConcurrentHashMap<K,V> clone(ConcurrentHashMap<K,V> map)
      Clones a given ConcurrentHashMap by creating a new map and copying all entries from the original map. If the value of an entry is a Set or an ArrayList, 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.