Package io.keikai.doc.collab.lib0
Class Maps
java.lang.Object
io.keikai.doc.collab.lib0.Maps
Map Utility
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> boolean all(Map<K, V> m, BiPredicate<V, K> f) Tests whether all key-value pairs pass the test implemented by the provided function.static <K,V> boolean any(Map<K, V> m, BiPredicate<V, K> f) Tests whether any key-value pairs pass the test implemented by the provided function.static <K,V> Map<K, V> Copies a Map object into a fresh Map object.static <K,V> Map<K, V> create()Creates a new HashMap instance.static <K,V, R> List<R> map(Map<K, V> m, BiFunction<V, K, R> f) Creates a List and populates it with the content of all key-value pairs using the provided function.static <K,V> V setIfUndefined(Map<K, V> map, K key, Supplier<V> createT) Get map property.
-
Method Details
-
create
Creates a new HashMap instance.- Returns:
- A new HashMap instance.
-
copy
Copies a Map object into a fresh Map object.- Type Parameters:
K- The type of the keys.V- The type of the values.- Parameters:
m- The Map to copy.- Returns:
- A new Map containing the same key-value pairs as the input Map.
-
setIfUndefined
Get map property. Create the value using the provided supplier if the key is undefined and set the value in the map.- Type Parameters:
K- The type of the key.V- The type of the value.- Parameters:
map- The Map to operate on.key- The key to check in the map.createT- A Supplier function to create the value if it doesn't exist in the map.- Returns:
- The value associated with the key.
-
map
Creates a List and populates it with the content of all key-value pairs using the provided function.- Type Parameters:
K- The type of the key.V- The type of the value.R- The type of the result produced by the function.- Parameters:
m- The Map to operate on.f- The function to apply to each key-value pair.- Returns:
- A List of results.
-
any
Tests whether any key-value pairs pass the test implemented by the provided function.- Type Parameters:
K- The type of the key.V- The type of the value.- Parameters:
m- The Map to operate on.f- The predicate function to apply to each key-value pair.- Returns:
- True if any key-value pair passes the test, false otherwise.
-
all
Tests whether all key-value pairs pass the test implemented by the provided function.- Type Parameters:
K- The type of the key.V- The type of the value.- Parameters:
m- The Map to operate on.f- The predicate function to apply to each key-value pair.- Returns:
- True if all key-value pairs pass the test, false otherwise.
-