Class ImmutableMapFacade<K,V>

java.lang.Object
org.jhotdraw8.icollection.readonly.AbstractReadOnlyMap<K,V>
org.jhotdraw8.icollection.facade.ImmutableMapFacade<K,V>
Type Parameters:
K - the key type
V - the element type
All Implemented Interfaces:
Iterable<Map.Entry<K,V>>, ImmutableMap<K,V>, ReadOnlyMap<K,V>

public class ImmutableMapFacade<K,V> extends AbstractReadOnlyMap<K,V> implements ImmutableMap<K,V>
Provides a ImmutableMap facade to a set of ImmutableMap functions.
  • Constructor Details

  • Method Details

    • clear

      public @NonNull ImmutableMapFacade<K,V> clear()
      Description copied from interface: ImmutableMap
      Returns a copy of this map that is empty.
      Specified by:
      clear in interface ImmutableMap<K,V>
      Returns:
      this set instance if it is already empty, or a different set instance that is empty.
    • put

      public @NonNull ImmutableMapFacade<K,V> put(@NonNull K key, @Nullable V value)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map with the specified entry added or updated.
      Specified by:
      put in interface ImmutableMap<K,V>
      Parameters:
      key - the key of the entry
      value - the value of the entry
      Returns:
      this map instance if it already contains the same entry, or a different map instance with the entry added or updated
    • putAll

      public @NonNull ImmutableMapFacade<K,V> putAll(@NonNull Iterable<? extends Map.Entry<? extends K,? extends V>> c)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map with entries from the specified map added or updated.
      Specified by:
      putAll in interface ImmutableMap<K,V>
      Parameters:
      c - another map
      Returns:
      this map instance if it already contains the same entries, or a different map instance with the entries added or updated
    • remove

      public @NonNull ImmutableMapFacade<K,V> remove(@NonNull K key)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map with the specified entry removed.
      Specified by:
      remove in interface ImmutableMap<K,V>
      Parameters:
      key - the key of the entry
      Returns:
      this map instance if it already does not contain the entry, or a different map instance with the entry removed
    • removeAll

      public @NonNull ImmutableMapFacade<K,V> removeAll(@NonNull Iterable<? extends K> c)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains all entries of this map except the entries of the specified collection.
      Specified by:
      removeAll in interface ImmutableMap<K,V>
      Parameters:
      c - a collection with keys of entries to be removed from this map
      Returns:
      this map instance if it already does not contain the entries, or a different map instance with the entries removed
    • retainAll

      public @NonNull ImmutableMapFacade<K,V> retainAll(@NonNull Iterable<? extends K> c)
      Description copied from interface: ImmutableMap
      Returns a copy of this map that contains only entries that are in this map and in the specified collection.
      Specified by:
      retainAll in interface ImmutableMap<K,V>
      Parameters:
      c - a collection with keys of entries to be retained in this map
      Returns:
      this map instance if it has not changed, or a different map instance with entries removed
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ReadOnlyMap
      Returns true if this map contains no entries.
      Specified by:
      isEmpty in interface ReadOnlyMap<K,V>
      Returns:
      true if empty
    • iterator

      public @NonNull Iterator<Map.Entry<K,V>> iterator()
      Description copied from interface: ReadOnlyMap
      Returns an iterator over the entries contained in this map.
      Specified by:
      iterator in interface Iterable<K>
      Specified by:
      iterator in interface ReadOnlyMap<K,V>
      Returns:
      an iterator
    • maxSize

      public int maxSize()
      Description copied from interface: ImmutableMap
      Returns the maximal number of entries that this map type can hold
      Specified by:
      maxSize in interface ImmutableMap<K,V>
      Returns:
      the maximal size
    • size

      public int size()
      Description copied from interface: ReadOnlyMap
      Returns the number of entries contained in this map..
      Specified by:
      size in interface ReadOnlyMap<K,V>
      Returns:
      the number of entries
    • get

      public @Nullable V get(Object key)
      Description copied from interface: ReadOnlyMap
      Returns the value to which the key is mapped, or null if this map contains no entry for the key.
      Specified by:
      get in interface ReadOnlyMap<K,V>
      Parameters:
      key - a key
      Returns:
      the mapped value or null
    • containsKey

      public boolean containsKey(@Nullable Object key)
      Description copied from interface: ReadOnlyMap
      Returns true if this map contains a entry for the specified key.
      Specified by:
      containsKey in interface ReadOnlyMap<K,V>
      Parameters:
      key - a key
      Returns:
      true if this map contains a entry for the specified key
    • toMutable

      public @NonNull Map<K,V> toMutable()
      Description copied from interface: ImmutableMap
      Returns a mutable copy of this map.
      Specified by:
      toMutable in interface ImmutableMap<K,V>
      Returns:
      a mutable copy.
    • characteristics

      public int characteristics()
      Description copied from interface: ReadOnlyMap
      Returns the spliterator characteristics of the key set. This implementation returns Spliterator.SIZED|Spliterator.DISTINCT.
      Specified by:
      characteristics in interface ReadOnlyMap<K,V>
      Returns:
      characteristics.