Package io.keikai.doc.collab.lib0
Class Maps
- java.lang.Object
-
- io.keikai.doc.collab.lib0.Maps
-
public class Maps extends java.lang.ObjectMap Utility
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
booleanall(java.util.Map<K,V> m, java.util.function.BiPredicate<V,K> f)Tests whether all key-value pairs pass the test implemented by the provided function.static <K,V>
booleanany(java.util.Map<K,V> m, java.util.function.BiPredicate<V,K> f)Tests whether any key-value pairs pass the test implemented by the provided function.static <K,V>
java.util.Map<K,V>copy(java.util.Map<K,V> m)Copies a Map object into a fresh Map object.static <K,V>
java.util.Map<K,V>create()Creates a new HashMap instance.static <K,V,R>
java.util.List<R>map(java.util.Map<K,V> m, java.util.function.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>
VsetIfUndefined(java.util.Map<K,V> map, K key, java.util.function.Supplier<V> createT)Get map property.
-
-
-
Method Detail
-
create
public static <K,V> java.util.Map<K,V> create()
Creates a new HashMap instance.- Returns:
- A new HashMap instance.
-
copy
public static <K,V> java.util.Map<K,V> copy(java.util.Map<K,V> m)
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
public static <K,V> V setIfUndefined(java.util.Map<K,V> map, K key, java.util.function.Supplier<V> createT)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
public static <K,V,R> java.util.List<R> map(java.util.Map<K,V> m, java.util.function.BiFunction<V,K,R> f)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
public static <K,V> boolean any(java.util.Map<K,V> m, java.util.function.BiPredicate<V,K> f)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
public static <K,V> boolean all(java.util.Map<K,V> m, java.util.function.BiPredicate<V,K> f)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.
-
-