# Class ParameterMap<K,V>

java.lang.Object
org.apache.catalina.util.ParameterMap<K,V>

Type Parameters:
  `K` - The type of Key
  `V` - The type of Value

All Implemented Interfaces:
  `Serializable, Map<K,V>`

public final class ParameterMap<K,V> extends Object implements Map<K,V>, Serializable
Implementation of java.util.Map that includes a `locked` property. This class can be used to safely expose Catalina internal parameter map objects to user classes without having to clone them in order to avoid modifications. When first created, a `ParameterMap` instance is not locked.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Map

  `Map.Entry<K,V>`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ParameterMap()`
  Construct a new, empty map with the default initial capacity and load factor.
  `ParameterMap(int initialCapacity)`
  Construct a new, empty map with the specified initial capacity and default load factor.
  `ParameterMap(int initialCapacity, float loadFactor)`
  Construct a new, empty map with the specified initial capacity and load factor.
  `ParameterMap(Map<K,V> map)`
  Construct a new map with the same mappings as the given map.
  `ParameterMap(ParameterMap<K,V> map)`
  Optimised constructor for ParameterMap.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  `boolean`
  `containsKey(Object key)`
  `boolean`
  `containsValue(Object value)`
  `Set<Map.Entry<K,V>>`
  `entrySet()`
  `V`
  `get(Object key)`
  `boolean`
  `isEmpty()`
  `boolean`
  `isLocked()`
  Returns the current lock state of this parameter map.
  `Set<K>`
  `keySet()`
  `V`
  `put(K key, V value)`
  `void`
  `putAll(Map<? extends K, ? extends V> map)`
  `V`
  `remove(Object key)`
  `void`
  `setLocked(boolean locked)`
  Set the locked state of this parameter map.
  `int`
  `size()`
  `Collection<V>`
  `values()`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface Map

  `compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll`

- ## Constructor Details

  - ### ParameterMap

    public ParameterMap()
    Construct a new, empty map with the default initial capacity and load factor.

  - ### ParameterMap

    public ParameterMap(int initialCapacity)
    Construct a new, empty map with the specified initial capacity and default load factor.
    Parameters:
      `initialCapacity` - The initial capacity of this map

  - ### ParameterMap

    public ParameterMap(int initialCapacity, float loadFactor)
    Construct a new, empty map with the specified initial capacity and load factor.
    Parameters:
      `initialCapacity` - The initial capacity of this map
      `loadFactor` - The load factor of this map

  - ### ParameterMap

    public ParameterMap(Map<K,V> map)
    Construct a new map with the same mappings as the given map.
    Parameters:
      `map` - Map whose contents are duplicated in the new map

  - ### ParameterMap

    public ParameterMap(ParameterMap<K,V> map)
    Optimised constructor for ParameterMap.
    Parameters:
      `map` - Map whose contents are duplicated in the new map
    See Also:
      - "https://bz.apache.org/bugzilla/show_bug.cgi?id=69285"

- ## Method Details

  - ### isLocked

    public boolean isLocked()
    Returns the current lock state of this parameter map.
    Returns:
      the locked state of this parameter map.

  - ### setLocked

    public void setLocked(boolean locked)
    Set the locked state of this parameter map.
    Parameters:
      `locked` - The new locked state

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Map<K,V>`
    Throws:
      `IllegalStateException` - if this map is currently locked

  - ### put

    public V put(K key, V value)
    Specified by:
      `put` in interface `Map<K,V>`
    Throws:
      `IllegalStateException` - if this map is currently locked

  - ### putAll

    public void putAll(Map<? extends K, ? extends V> map)
    Specified by:
      `putAll` in interface `Map<K,V>`
    Throws:
      `IllegalStateException` - if this map is currently locked

  - ### remove

    public V remove(Object key)
    Specified by:
      `remove` in interface `Map<K,V>`
    Throws:
      `IllegalStateException` - if this map is currently locked

  - ### size

    public int size()
    Specified by:
      `size` in interface `Map<K,V>`

  - ### isEmpty

    public boolean isEmpty()
    Specified by:
      `isEmpty` in interface `Map<K,V>`

  - ### containsKey

    public boolean containsKey(Object key)
    Specified by:
      `containsKey` in interface `Map<K,V>`

  - ### containsValue

    public boolean containsValue(Object value)
    Specified by:
      `containsValue` in interface `Map<K,V>`

  - ### get

    public V get(Object key)
    Specified by:
      `get` in interface `Map<K,V>`

  - ### keySet

    public Set<K> keySet()

    Returns an unmodifiable `Set` view of the keys contained in this map if it is locked.

    Specified by:
      `keySet` in interface `Map<K,V>`

  - ### values

    public Collection<V> values()

    Returns an unmodifiable `Collection` view of the values contained in this map if it is locked.

    Specified by:
      `values` in interface `Map<K,V>`

  - ### entrySet

    public Set<Map.Entry<K,V>> entrySet()

    Returns an unmodifiable `Set` view of the mappings contained in this map if it is locked.

    Specified by:
      `entrySet` in interface `Map<K,V>`