Class MapDecorator<K,V>

java.lang.Object
org.forgerock.util.MapDecorator<K,V>
Type Parameters:
K - The type of key.
V - The type of value.
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
CaseInsensitiveMap, MultiValueMap

public class MapDecorator<K,V> extends Object implements Map<K,V>
Wraps another map. All methods simply call through to the wrapped map. Subclasses are expected to override one or more of these methods.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.Map

    Map.Entry<K,V>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Map<K,V>
    The map wrapped by this decorator.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new map decorator, wrapping the specified map.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all of the mappings from the map.
    boolean
    Returns true if this map contains a mapping for the specified key.
    boolean
    Returns true if the map maps one or more keys to the specified value.
    Returns a Set view of the mappings contained in the map.
    boolean
    Compares the specified object with the map for equality.
    get(Object key)
    Returns the value to which the specified key is mapped, or null if the map contains no mapping for the key.
    int
    Returns the hash code value for the map.
    boolean
    Returns true if the map contains no key-value mappings.
    Returns a Set view of the keys contained in the map.
    put(K key, V value)
    Associates the specified value with the specified key in the map.
    void
    putAll(Map<? extends K,? extends V> m)
    Copies all of the mappings from the specified map to the map.
    Removes the mapping for a key from the map if it is present.
    int
    Returns the number of key-value mappings in this map.
    Returns a Collection view of the values contained in the map.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • map

      protected final Map<K,V> map
      The map wrapped by this decorator.
  • Constructor Details

    • MapDecorator

      public MapDecorator(Map<K,V> map)
      Constructs a new map decorator, wrapping the specified map.
      Parameters:
      map - the map to wrap with the decorator.
      Throws:
      NullPointerException - if map is null.
  • Method Details

    • size

      public int size()
      Returns the number of key-value mappings in this map.
      Specified by:
      size in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Returns true if the map contains no key-value mappings.
      Specified by:
      isEmpty in interface Map<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Returns true if this map contains a mapping for the specified key.
      Specified by:
      containsKey in interface Map<K,V>
      Parameters:
      key - the key whose presence in this map is to be tested.
      Returns:
      true if this map contains a mapping for the specified key.
    • containsValue

      public boolean containsValue(Object value)
      Returns true if the map maps one or more keys to the specified value.
      Specified by:
      containsValue in interface Map<K,V>
      Parameters:
      value - the value whose presence in the map is to be tested.
      Returns:
      true if the map maps one or more keys to the specified value.
    • get

      public V get(Object key)
      Returns the value to which the specified key is mapped, or null if the map contains no mapping for the key.
      Specified by:
      get in interface Map<K,V>
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped, or null if no mapping.
    • put

      public V put(K key, V value)
      Associates the specified value with the specified key in the map.
      Specified by:
      put in interface Map<K,V>
      Parameters:
      key - key with which the specified value is to be associated.
      value - value to be associated with the specified key.
      Returns:
      the previous value associated with key, or null if no mapping.
    • remove

      public V remove(Object key)
      Removes the mapping for a key from the map if it is present.
      Specified by:
      remove in interface Map<K,V>
      Parameters:
      key - key whose mapping is to be removed from the map.
      Returns:
      the previous value associated with key, or null if no mapping.
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
      Copies all of the mappings from the specified map to the map.
      Specified by:
      putAll in interface Map<K,V>
      Parameters:
      m - mappings to be stored in the map.
    • clear

      public void clear()
      Removes all of the mappings from the map.
      Specified by:
      clear in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Returns a Set view of the keys contained in the map.
      Specified by:
      keySet in interface Map<K,V>
    • values

      public Collection<V> values()
      Returns a Collection view of the values contained in the map.
      Specified by:
      values in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Returns a Set view of the mappings contained in the map.
      Specified by:
      entrySet in interface Map<K,V>
    • hashCode

      public int hashCode()
      Returns the hash code value for the map.
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Compares the specified object with the map for equality.
      Specified by:
      equals in interface Map<K,V>
      Overrides:
      equals in class Object
      Parameters:
      o - object to be compared for equality with the map.
      Returns:
      true if the specified object is equal to the map.