Class MutableParameterMap<P,T>

java.lang.Object
org.apache.commons.chain.web.ParameterMap<P,T>
org.apache.commons.chain.web.MutableParameterMap<P,T>
Type Parameters:
P - the type of the parameter-provider
T - the type of results supplied by this parameters
All Implemented Interfaces:
Map<String,T>

public class MutableParameterMap<P,T> extends ParameterMap<P,T>
Implementation of Map for mutable parameters with a parameter-provider.
Since:
Chain 1.3
Author:
Graff Stefan
  • Constructor Details

    • MutableParameterMap

      public MutableParameterMap(P parameter, Function<String,T> valueFunction, Supplier<Enumeration<String>> namesSupplier, Consumer<String> removeConsumer, BiConsumer<String,T> setConsumer)
      The constructor for an mutable parameter-map.
      Parameters:
      parameter - the parameter-provider
      valueFunction - Function to return the value of a parameter
      namesSupplier - Supplier to return all names of the parameter
      removeConsumer - Consumer to remove a value of the parameter
      setConsumer - BiConsumer to stores a value of the parameter
  • Method Details

    • clear

      public void clear()
      Removes all of the mappings from this parameter-map. The parameter-map will be empty after this call returns.
      Specified by:
      clear in interface Map<P,T>
      Overrides:
      clear in class ParameterMap<P,T>
    • containsValue

      public boolean containsValue(Object value)
      Returns true if this parameter-map maps one or more keys to the specified value.
      Specified by:
      containsValue in interface Map<P,T>
      Overrides:
      containsValue in class ParameterMap<P,T>
      Parameters:
      value - value whose presence in this parameter-map is to be tested
      Returns:
      true if this parameter-map maps one or more keys to the specified value
    • entrySet

      Returns a Set view of the mappings contained in this parameter-map. The set is not backed by the parameter-map, so changes to the parameter-map are not reflected in the set, and vice-versa.
      Specified by:
      entrySet in interface Map<P,T>
      Overrides:
      entrySet in class ParameterMap<P,T>
      Returns:
      a set view of the mappings contained in this parameter-map
    • put

      public T put(String key, T value)
      Associates the specified value with the specified key in this parameter-map. If the parameter-map previously contained a mapping for the key, the old value is replaced.
      Specified by:
      put in interface Map<P,T>
      Overrides:
      put in class ParameterMap<P,T>
      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 there was no mapping for key. (A null return can also indicate that the parameter-map previously associated null with key.)
    • putAll

      public void putAll(Map<? extends String,? extends T> map)
      Copies all of the mappings from the specified map to this parameter-map. These mappings will replace any mappings that this parameter-map had for any of the keys currently in the specified map.
      Specified by:
      putAll in interface Map<P,T>
      Overrides:
      putAll in class ParameterMap<P,T>
      Parameters:
      map - mappings to be stored in this parameter-map
      Throws:
      NullPointerException - if the specified map is null
    • remove

      public T remove(Object key)
      Removes the mapping for the specified key from this parameter-map if present.
      Specified by:
      remove in interface Map<P,T>
      Overrides:
      remove in class ParameterMap<P,T>
      Parameters:
      key - key whose mapping is to be removed from the parameter-map
      Returns:
      the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the parameter-map previously associated null with key.)
    • hashCode

      public int hashCode()
      Returns the hash code value for this parameter-map. The hash code of a parameter-map is defined to be the sum of the hash codes of each entry in the parameter-map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two parameter-maps m1 and m2, as required by the general contract of Object.hashCode().
      Specified by:
      hashCode in interface Map<P,T>
      Overrides:
      hashCode in class ParameterMap<P,T>
      Returns:
      the hash code value for this parameter-map
      Implementation Requirements:
      This implementation calls the hashCode() from the parameter-provider.
    • equals

      public boolean equals(Object obj)
      Compares the specified object with this parameter-map for equality. Returns true if the given object is also a parameter-map and the two parameter-maps represent the same mappings. More formally, two parameter-maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()).
      Specified by:
      equals in interface Map<P,T>
      Overrides:
      equals in class ParameterMap<P,T>
      Parameters:
      obj - object to be compared for equality with this parameter-map
      Returns:
      true if the specified object is equal to this parameter-map
      Implementation Requirements:
      This implementation first checks if the specified object is this parameter-map; if so it returns true. Then, it checks if the specified object is the identical class this parameter-map; if not, it returns false. If so, it calls the equals() from the parameter-provider and returns its return-code.