Class Collections
java.lang.Object
org.openprovenance.prov.template.compiler.sql.Collections
Provides static utility methods for working with collections.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> List<E> emptyListOf(Class<E> elementType) Returns an empty list.static <K,V> Map <K, V> emptyMapOf(Class<K> keyType, Class<V> valueType) Returns an empty map.static <K,V> Map.Entry <K, V> entry(K key, V value) Creates an immutable map entry.static <E> intfirstIndexWhere(List<E> list, Predicate<E> predicate) Returns the index of the first element in a list that matches the given predicate.static <E> intlastIndexWhere(List<E> list, Predicate<E> predicate) Returns the index of the last element in a list that matches the given predicate.static <E> List<E> listOf(E... elements) Creates an immutable list of elements.static <K,V> Map <K, V> Creates an immutable map of entries.static ObjectReturns the value at a given path.
-
Method Details
-
listOf
Creates an immutable list of elements.- Type Parameters:
E- The element type.- Parameters:
elements- The list elements.- Returns:
- An immutable list containing the provided elements.
-
mapOf
Creates an immutable map of entries.- Type Parameters:
K- The key type.V- The value type.- Parameters:
entries- The map entries.- Returns:
- An immutable map containing the provided entries.
-
entry
Creates an immutable map entry.- Type Parameters:
K- The key type.V- The value type.- Parameters:
key- The entry key.value- The entry value.- Returns:
- An immutable map entry containing the provided key/value pair.
-
emptyListOf
Returns an empty list.- Type Parameters:
E- The element type.- Parameters:
elementType- The element type.- Returns:
- An empty list.
-
emptyMapOf
Returns an empty map.- Type Parameters:
K- The key type.V- The value type.- Parameters:
keyType- The key type.valueType- The value type.- Returns:
- An empty map.
-
firstIndexWhere
Returns the index of the first element in a list that matches the given predicate.- Type Parameters:
E- The element type.- Parameters:
list- The list of elements.predicate- The predicate.- Returns:
- The index of the first matching element, or
-1if no match was found.
-
lastIndexWhere
Returns the index of the last element in a list that matches the given predicate.- Type Parameters:
E- The element type.- Parameters:
list- The list of elements.predicate- The predicate.- Returns:
- The index of the last matching element, or
-1if no match was found.
-
valueAt
Returns the value at a given path.- Parameters:
root- The root object.path- The path to the value.- Returns:
- The value at the given path, or
nullif the value does not exist.
-