Class Maps

java.lang.Object
io.keikai.doc.collab.lib0.Maps

public class Maps extends Object
Map Utility
  • Method Summary

    Modifier and Type
    Method
    Description
    static <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>
    copy(Map<K,V> m)
    Copies a Map object into a fresh Map object.
    static <K, V> Map<K,V>
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static <K, V> Map<K,V> create()
      Creates a new HashMap instance.
      Returns:
      A new HashMap instance.
    • copy

      public static <K, V> Map<K,V> copy(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(Map<K,V> map, K key, 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> 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.
      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(Map<K,V> m, 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(Map<K,V> m, 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.