Class CollectionUtils

java.lang.Object
net.ontopia.utils.CollectionUtils

public class CollectionUtils extends Object
INTERNAL: Class that contains useful collection methods.
  • Method Details

    • getFirst

      public static <T> T getFirst(Collection<T> coll)
      INTERNAL: Gets the first object in the collection. If the collection is empty, null is returned.
    • getFirstElement

      public static <T> T getFirstElement(Collection<T> coll)
      INTERNAL: Gets the first object in the collection. If the collection does not contain any elements NoSuchElementException is thrown.

      Since:
      1.3.4
    • getRandom

      public static <T> T getRandom(Collection<T> coll)
      INTERNAL: Gets a random object from the collection. If the collection is empty, null is returned.
    • equalsUnorderedSet

      public static <T> boolean equalsUnorderedSet(Collection<T> coll1, Collection<T> coll2)
      INTERNAL: Compares two collections to see if they contain the same elements.
      Since:
      1.4.1
    • nextBatch

      public static <T> List<T> nextBatch(Iterator<T> iter, int length)
      EXPERIMENTAL: Iterates over up to length number of elements in the iterator and returns those elements as a Collection. If the iterator is exhausted only the iterated elements are returned.