Package org.httprpc.util
Class Collections
- java.lang.Object
-
- org.httprpc.util.Collections
-
public class Collections extends java.lang.ObjectClass that provides static utility methods for working with collections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
java.util.Map.Entry<K,V>entry(K key, V value)Creates an immutable map entry.static <E> java.util.List<E>listOf(E... elements)Creates an immutable list of elements.static <K,V>
java.util.Map<K,V>mapOf(java.util.Map.Entry<K,V>... entries)Creates an immutable map of entries.static <T> TvalueAt(java.lang.Object root, java.lang.Object... path)Returns the value at a given path.
-
-
-
Method Detail
-
listOf
@SafeVarargs public static <E> java.util.List<E> listOf(E... elements)
Creates an immutable list of elements.- Type Parameters:
E- The type of the elements in the list.- Parameters:
elements- The list elements.- Returns:
- An immutable list containing the provided elements.
-
mapOf
@SafeVarargs public static <K,V> java.util.Map<K,V> mapOf(java.util.Map.Entry<K,V>... entries)
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
public static <K,V> java.util.Map.Entry<K,V> entry(K key, V value)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.
-
valueAt
public static <T> T valueAt(java.lang.Object root, java.lang.Object... path)Returns the value at a given path.- Type Parameters:
T- The type of the value to return.- 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.
-
-