Class CollectionUtils

java.lang.Object
org.opends.server.util.CollectionUtils

public final class CollectionUtils extends Object
Utility class for Collections.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E, C extends Collection<E>>
    void
    addAll(C dest, Iterable<E> source)
    Adds all the elements from the provided iterable into the provided collection.
    static <C extends Collection<E>, E>
    C
    collect(Iterable<E> iterable, C outputCollection)
    Collects all the elements from the provided iterable into the provided collection.
    static <E> ArrayList<E>
    newArrayList(E... elements)
    Creates a new ArrayList with the provided elements.
    static <E> HashSet<E>
    newHashSet(E... elements)
    Creates a new HashSet with the provided elements.
    static <E> LinkedList<E>
    newLinkedList(E... elements)
    Creates a new LinkedList with the provided elements.
    static <E> TreeSet<E>
    newTreeSet(E... elements)
    Creates a new TreeSet with the provided elements.
    static <K, V> Map<K,V>
    treeMapOf(K k1, V v1)
    Returns a new hashmap with the provided mapping.
    static <K, V> Map<K,V>
    treeMapOf(K k1, V v1, K k2, V v2)
    Returns a new hashmap with the provided mapping.
    static <K, V> Map<K,V>
    treeMapOf(K k1, V v1, K k2, V v2, K k3, V v3)
    Returns a new hashmap with the provided mapping.
    static <K, V> Map<K,V>
    treeMapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
    Returns a new hashmap with the provided mapping.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • newArrayList

      @SafeVarargs public static <E> ArrayList<E> newArrayList(E... elements)
      Creates a new ArrayList with the provided elements.
      Type Parameters:
      E - the elements' type
      Parameters:
      elements - the elements to add to the new ArrayList
      Returns:
      a new ArrayList with the provided elements
    • newLinkedList

      @SafeVarargs public static <E> LinkedList<E> newLinkedList(E... elements)
      Creates a new LinkedList with the provided elements.
      Type Parameters:
      E - the elements' type
      Parameters:
      elements - the elements to add to the new LinkedList
      Returns:
      a new LinkedList with the provided elements
    • newHashSet

      @SafeVarargs public static <E> HashSet<E> newHashSet(E... elements)
      Creates a new HashSet with the provided elements.
      Type Parameters:
      E - the elements' type
      Parameters:
      elements - the elements to add to the new HashSet
      Returns:
      a new HashSet with the provided elements
    • newTreeSet

      @SafeVarargs public static <E> TreeSet<E> newTreeSet(E... elements)
      Creates a new TreeSet with the provided elements.
      Type Parameters:
      E - the elements' type
      Parameters:
      elements - the elements to add to the new TreeSet
      Returns:
      a new TreeSet with the provided elements
    • collect

      public static <C extends Collection<E>, E> C collect(Iterable<E> iterable, C outputCollection)
      Collects all the elements from the provided iterable into the provided collection.
      Type Parameters:
      C - The type of the collection
      E - The type of the iterable's elements
      Parameters:
      iterable - the iterable from which to read elements
      outputCollection - the collection where to add the iterable's elements
      Returns:
      the provided collection
    • addAll

      public static <E, C extends Collection<E>> void addAll(C dest, Iterable<E> source)
      Adds all the elements from the provided iterable into the provided collection.
      Type Parameters:
      E - type of the elements to add
      C - type of the collection where to add
      Parameters:
      dest - the collection where elements will be added
      source - the iterable where elements will be read from
    • treeMapOf

      public static <K, V> Map<K,V> treeMapOf(K k1, V v1)
      Returns a new hashmap with the provided mapping.
      Type Parameters:
      K - type of the keys
      V - type of the values
      Parameters:
      k1 - the first key
      v1 - the first value
      Returns:
      a new hashmap with the provided mapping.
    • treeMapOf

      public static <K, V> Map<K,V> treeMapOf(K k1, V v1, K k2, V v2)
      Returns a new hashmap with the provided mapping.
      Type Parameters:
      K - type of the keys
      V - type of the values
      Parameters:
      k1 - the first key
      v1 - the first value
      k2 - the second key
      v2 - the second value
      Returns:
      a new hashmap with the provided mapping.
    • treeMapOf

      public static <K, V> Map<K,V> treeMapOf(K k1, V v1, K k2, V v2, K k3, V v3)
      Returns a new hashmap with the provided mapping.
      Type Parameters:
      K - type of the keys
      V - type of the values
      Parameters:
      k1 - the first key
      v1 - the first value
      k2 - the second key
      v2 - the second value
      k3 - the third key
      v3 - the third value
      Returns:
      a new hashmap with the provided mapping.
    • treeMapOf

      public static <K, V> Map<K,V> treeMapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
      Returns a new hashmap with the provided mapping.
      Type Parameters:
      K - type of the keys
      V - type of the values
      Parameters:
      k1 - the first key
      v1 - the first value
      k2 - the second key
      v2 - the second value
      k3 - the third key
      v3 - the third value
      k4 - the fourth key
      v4 - the fourth value
      Returns:
      a new hashmap with the provided mapping.