Class Map<K,V>

java.lang.Object
me.sbasalaev.collection.Multimap<K,V,Opt<V>>
me.sbasalaev.collection.Map<K,V>
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
MutableMap

public abstract class Map<K,@Out V> extends Multimap<K,V,Opt<V>> implements Cloneable
Mapping of keys to values.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Builder of immutable maps.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Map()
    Constructor for subclasses.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K, V> Map.Builder<K,V>
    Builds map from given entries.
    final Map<K,V>
    Returns shallow immutable copy of this map.
    Associations between keys and collections of values in this multimap.
    static <K, V> Map<K,V>
    Map with no entries.
    abstract Set<Entry<K,V>>
    The set of key-value associations in this map.
    boolean
    Whether some object is equal to this map.
    void
    Performs given action for each entry in this map.
    static <K, V> Map<K,V>
    fromJava(Map<K,V> javaMap)
    Map view of given java map.
    abstract Opt<V>
    get(Object key)
    Value associated with given key or empty optional if there is none.
    The set of keys that have an associated value in this map.
    int
    Number of keys in this map.
    <W> Map<K,W>
    mapValues(Function<? super @Out V,? extends W> mapping)
    View of this map with given mapping applied to values.
    static <K, V> Map<K,V>
    of(K key, V value)
    Map containing given entry.
    static <K, V> Map<K,V>
    of(K k1, V v1, K k2, V v2)
    Map containing given entries.
    static <K, V> Map<K,V>
    of(K k1, V v1, K k2, V v2, K k3, V v3)
    Map containing given entries.
    static <K, V> Map<K,V>
    of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
    Map containing given entries.
    static <K, V> Map<K,V>
    of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
    Map containing given entries.
    static <K, V> Map<K,V>
    of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)
    Map containing given entries.
    View of this map as java map.

    Methods inherited from class me.sbasalaev.collection.Multimap

    containsEntry, containsEntry, containsKey, hashCode, isEmpty, nonEmpty, size, toString, values

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Map

      public Map()
      Constructor for subclasses.
  • Method Details

    • empty

      public static <K, V> Map<K,V> empty()
      Map with no entries.
    • of

      public static <K, V> Map<K,V> of(K key, V value)
      Map containing given entry.
    • of

      public static <K, V> Map<K,V> of(K k1, V v1, K k2, V v2)
      Map containing given entries.
    • of

      public static <K, V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3)
      Map containing given entries.
    • of

      public static <K, V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
      Map containing given entries.
    • of

      public static <K, V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
      Map containing given entries.
    • of

      public static <K, V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)
      Map containing given entries.
    • build

      public static <K, V> Map.Builder<K,V> build()
      Builds map from given entries.
    • fromJava

      public static <K, V> Map<K,V> fromJava(Map<K,V> javaMap)
      Map view of given java map.
    • get

      public abstract Opt<V> get(Object key)
      Value associated with given key or empty optional if there is none.
      Specified by:
      get in class Multimap<K,V,Opt<V>>
    • keySize

      public int keySize()
      Number of keys in this map. For the map this method returns the same value as size().
      Specified by:
      keySize in class Multimap<K,V,Opt<V>>
      Since:
      3.2
    • entries

      public abstract Set<Entry<K,V>> entries()
      The set of key-value associations in this map.
      Specified by:
      entries in class Multimap<K,V,Opt<V>>
    • collectionEntries

      public Set<Entry<K,Opt<V>>> collectionEntries()
      Description copied from class: Multimap
      Associations between keys and collections of values in this multimap.
      Specified by:
      collectionEntries in class Multimap<K,V,Opt<V>>
    • keys

      public Set<K> keys()
      The set of keys that have an associated value in this map.
      Overrides:
      keys in class Multimap<K,V,Opt<V>>
    • mapValues

      public <W> Map<K,W> mapValues(Function<? super @Out V,? extends W> mapping)
      View of this map with given mapping applied to values.
    • forEachEntry

      public void forEachEntry(BiConsumer<K,@Out V> action)
      Performs given action for each entry in this map.
      Since:
      4.1
    • toJava

      public Map<K,V> toJava()
      View of this map as java map.
    • clone

      public final Map<K,V> clone()
      Returns shallow immutable copy of this map.
      Specified by:
      clone in class Multimap<K,V,Opt<V>>
    • equals

      public boolean equals(@Nullable Object obj)
      Whether some object is equal to this map. Two maps are equal if they contain the same entries, i.e. their entries() methods return equal sets.
      Specified by:
      equals in class Multimap<K,V,Opt<V>>