Package org.apache.commons.chain.web
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-providerT
- the type of results supplied by this parameters
Implementation of
Map
for mutable parameters with a
parameter-provider.- Since:
- Chain 1.3
- Author:
- Graff Stefan
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionMutableParameterMap
(P parameter, Function<String, T> valueFunction, Supplier<Enumeration<String>> namesSupplier, Consumer<String> removeConsumer, BiConsumer<String, T> setConsumer) The constructor for an mutable parameter-map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all of the mappings from this parameter-map.boolean
containsValue
(Object value) Returnstrue
if this parameter-map maps one or more keys to the specified value.entrySet()
Returns aSet
view of the mappings contained in this parameter-map.boolean
Compares the specified object with this parameter-map for equality.int
hashCode()
Returns the hash code value for this parameter-map.Associates the specified value with the specified key in this parameter-map.void
Copies all of the mappings from the specified map to this parameter-map.Removes the mapping for the specified key from this parameter-map if present.Methods inherited from class org.apache.commons.chain.web.ParameterMap
containsKey, entrySet, get, getNamesSupplier, getParameter, getValueFunction, isEmpty, key, keySet, size, toString, values
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
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-providervalueFunction
- Function to return the value of a parameternamesSupplier
- Supplier to return all names of the parameterremoveConsumer
- Consumer to remove a value of the parametersetConsumer
- BiConsumer to stores a value of the parameter
-
-
Method Details
-
clear
Removes all of the mappings from this parameter-map. The parameter-map will be empty after this call returns. -
containsValue
Returnstrue
if this parameter-map maps one or more keys to the specified value.- Specified by:
containsValue
in interfaceMap<P,
T> - Overrides:
containsValue
in classParameterMap<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 aSet
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. -
put
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 interfaceMap<P,
T> - Overrides:
put
in classParameterMap<P,
T> - Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- the previous value associated with
key
, ornull
if there was no mapping forkey
. (Anull
return can also indicate that the parameter-map previously associatednull
withkey
.)
-
putAll
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 interfaceMap<P,
T> - Overrides:
putAll
in classParameterMap<P,
T> - Parameters:
map
- mappings to be stored in this parameter-map- Throws:
NullPointerException
- if the specified map is null
-
remove
Removes the mapping for the specified key from this parameter-map if present.- Specified by:
remove
in interfaceMap<P,
T> - Overrides:
remove
in classParameterMap<P,
T> - Parameters:
key
- key whose mapping is to be removed from the parameter-map- Returns:
- the previous value associated with
key
, ornull
if there was no mapping forkey
. (Anull
return can also indicate that the parameter-map previously associatednull
withkey
.)
-
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'sentrySet()
view. This ensures thatm1.equals(m2)
implies thatm1.hashCode()==m2.hashCode()
for any two parameter-mapsm1
andm2
, as required by the general contract ofObject.hashCode()
. -
equals
Compares the specified object with this parameter-map for equality. Returnstrue
if the given object is also a parameter-map and the two parameter-maps represent the same mappings. More formally, two parameter-mapsm1
andm2
represent the same mappings ifm1.entrySet().equals(m2.entrySet())
.- Specified by:
equals
in interfaceMap<P,
T> - Overrides:
equals
in classParameterMap<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 returnsfalse
. If so, it calls theequals()
from the parameter-provider and returns its return-code.
-