Package net.ontopia.utils
Class CollectionUtils
- java.lang.Object
-
- net.ontopia.utils.CollectionUtils
-
public class CollectionUtils extends Object
INTERNAL: Class that contains useful collection methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> boolean
equalsUnorderedSet(Collection<T> coll1, Collection<T> coll2)
INTERNAL: Compares two collections to see if they contain the same elements.static <T> T
getFirst(Collection<T> coll)
INTERNAL: Gets the first object in the collection.static <T> T
getFirstElement(Collection<T> coll)
INTERNAL: Gets the first object in the collection.static <T> T
getRandom(Collection<T> coll)
INTERNAL: Gets a random object from the collection.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.
-
-
-
Method Detail
-
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
-
-