Class Collections

java.lang.Object
org.opencastproject.util.data.Collections

@Deprecated public final class Collections extends Object
Deprecated.
By now, all of this is natively available in Java.
This class provides functions to ease and secure the handling of collections by supporting a type safe -- at least to the extent Java's type system allows -- immutable and more functional style. Note that all functions do not mutate input collections unless otherwise stated.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <A, T extends Collection<A>, S extends Iterable<? extends A>>
    T
    appendTo(T target, S as)
    Deprecated.
    Append source collection as to target.
    static <A, T extends Collection<A>, X extends A>
    T
    appendToA(T target, X... as)
    Deprecated.
    Append source collections as to target.
    static <A, T extends Collection<A>, S extends Iterable<? extends A>>
    T
    appendToM(T target, S... as)
    Deprecated.
    Append source collections as to target.
    static <A, M extends Collection<? extends Collection<A>>>
    List<A>
    concat(M as)
    Deprecated.
    Concat (aka flatten) a collection of collections by concatenating them all.
    static <A, M extends Iterable<? extends A>>
    List<A>
    concat(M as, M bs)
    Deprecated.
    Concatenates two iterables into a new list.
    static <A> List<A>
    cons(A a, List<? extends A> as)
    Deprecated.
    Construct a new list by prepending an element to a given list.
    static <K, V> Dictionary<K,V>
    dict(Tuple<? extends K,? extends V>... ts)
    Deprecated.
    Create a dictionary from a list of tuples (K, V).
    static <A> Iterable<A>
    forc(Iterator<A> as)
    Deprecated.
    Make an Iterator usable in a for comprehension like this:
    static <A> Optional<A>
    head(List<A> as)
    Deprecated.
    Return the head of list as or none.
    static <A> Iterator<A>
    iterator(A... as)
    Deprecated.
    Create an iterator form an array.
    static <A> Iterator<A>
    join(Iterator<A> a, Iterator<A> b)
    Deprecated.
    Join two iterators.
    static <A> List<A>
    list(A... as)
    Deprecated.
    Create a list from an array.
    static <K, V> Map<K,V>
    map(Tuple<? extends K,? extends V>... ts)
    Deprecated.
    Create a map from a list of tuples (K, V).
    static <A, B> Map<A,B>
    merge(Map<? extends A,? extends B> a, Map<? extends A,? extends B> b)
    Deprecated.
    Merge two maps where b takes precedence.
    static <A> List<A>
    mkList(List<A> as)
    Deprecated.
    static String
    mkString(Collection<?> as, String sep)
    Deprecated.
    Make a string from a collection separating each element by sep.
    static <A> List<A>
    nil()
    Deprecated.
    The empty list.
    static <A> List<A>
    nil(Class<A> type)
    Deprecated.
    The empty list.
    static <A> List<A>
    nonNullList(A... as)
    Deprecated.
    Create a list from an array.
    static <A> List<A>
    nullToNil(List<A> as)
    Deprecated.
    Return the list as is or nil, if as is null.
    static <A, X extends A>
    Iterator<A>
    repeat(X a, int times)
    Deprecated.
    Create an iterator that repeats a for the said times.
    static <A> Set<A>
    set(A... as)
    Deprecated.
    Create a set from an array.
    static <A, B extends A>
    A[]
    toArray(Class<A> elemType, Collection<B> a)
    Deprecated.
    Create an array from a collection.
    static double[]
    Deprecated.
    Convert a collection of Doubles into an array of primitive type.
    static <A> List<A>
    Deprecated.
    Drain all elements of as into a list.
    static <A> List<A>
    toList(Iterator<? extends A> as)
    Deprecated.
    Drain all elements of as into a list.
    static <A> Set<A>
    toSet(List<A> as)
    Deprecated.
    Create a set from a list.

    Methods inherited from class java.lang.Object

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

    • head

      public static <A> Optional<A> head(List<A> as)
      Deprecated.
      Return the head of list as or none.
    • mkString

      public static String mkString(Collection<?> as, String sep)
      Deprecated.
      Make a string from a collection separating each element by sep.
    • appendTo

      public static <A, T extends Collection<A>, S extends Iterable<? extends A>> T appendTo(T target, S as)
      Deprecated.
      Append source collection as to target.
    • appendToM

      @SafeVarargs public static <A, T extends Collection<A>, S extends Iterable<? extends A>> T appendToM(T target, S... as)
      Deprecated.
      Append source collections as to target.
    • appendToA

      @SafeVarargs public static <A, T extends Collection<A>, X extends A> T appendToA(T target, X... as)
      Deprecated.
      Append source collections as to target.
    • concat

      public static <A, M extends Iterable<? extends A>> List<A> concat(M as, M bs)
      Deprecated.
      Concatenates two iterables into a new list.
    • merge

      public static <A, B> Map<A,B> merge(Map<? extends A,? extends B> a, Map<? extends A,? extends B> b)
      Deprecated.
      Merge two maps where b takes precedence.
      Returns:
      a new immutable map
    • toList

      public static <A> List<A> toList(Iterator<? extends A> as)
      Deprecated.
      Drain all elements of as into a list.
    • toList

      public static <A> List<A> toList(Collection<A> as)
      Deprecated.
      Drain all elements of as into a list.
    • mkList

      @Deprecated public static <A> List<A> mkList(List<A> as)
      Deprecated.
      Return the list as is or nil, if as is null.
    • nullToNil

      public static <A> List<A> nullToNil(List<A> as)
      Deprecated.
      Return the list as is or nil, if as is null.
    • list

      @SafeVarargs public static <A> List<A> list(A... as)
      Deprecated.
      Create a list from an array.
    • nonNullList

      @SafeVarargs public static <A> List<A> nonNullList(A... as)
      Deprecated.
      Create a list from an array.
    • nil

      public static <A> List<A> nil()
      Deprecated.
      The empty list.
    • nil

      public static <A> List<A> nil(Class<A> type)
      Deprecated.
      The empty list.
    • cons

      public static <A> List<A> cons(A a, List<? extends A> as)
      Deprecated.
      Construct a new list by prepending an element to a given list.
    • set

      @SafeVarargs public static <A> Set<A> set(A... as)
      Deprecated.
      Create a set from an array.
    • toSet

      public static <A> Set<A> toSet(List<A> as)
      Deprecated.
      Create a set from a list.
    • map

      @SafeVarargs public static <K, V> Map<K,V> map(Tuple<? extends K,? extends V>... ts)
      Deprecated.
      Create a map from a list of tuples (K, V).
    • dict

      @SafeVarargs public static <K, V> Dictionary<K,V> dict(Tuple<? extends K,? extends V>... ts)
      Deprecated.
      Create a dictionary from a list of tuples (K, V).
    • toArray

      public static <A, B extends A> A[] toArray(Class<A> elemType, Collection<B> a)
      Deprecated.
      Create an array from a collection.
    • toDoubleArray

      public static double[] toDoubleArray(Collection<Double> as)
      Deprecated.
      Convert a collection of Doubles into an array of primitive type.
    • iterator

      @SafeVarargs public static <A> Iterator<A> iterator(A... as)
      Deprecated.
      Create an iterator form an array.
    • repeat

      public static <A, X extends A> Iterator<A> repeat(X a, int times)
      Deprecated.
      Create an iterator that repeats a for the said times.
    • join

      public static <A> Iterator<A> join(Iterator<A> a, Iterator<A> b)
      Deprecated.
      Join two iterators.
    • forc

      public static <A> Iterable<A> forc(Iterator<A> as)
      Deprecated.
      Make an Iterator usable in a for comprehension like this:
         Iterator<A> as = ...
         for (A a : forc(as)) {
           ...
         }
       
    • concat

      public static <A, M extends Collection<? extends Collection<A>>> List<A> concat(M as)
      Deprecated.
      Concat (aka flatten) a collection of collections by concatenating them all. [[a]] -> [a]