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
ConstructorsConstructorDescriptionMutableParameterMap(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 TypeMethodDescriptionvoidclear()Removes all of the mappings from this parameter-map.booleancontainsValue(Object value) Returnstrueif this parameter-map maps one or more keys to the specified value.entrySet()Returns aSetview of the mappings contained in this parameter-map.booleanCompares the specified object with this parameter-map for equality.inthashCode()Returns the hash code value for this parameter-map.Associates the specified value with the specified key in this parameter-map.voidCopies 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, valuesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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
Returnstrueif this parameter-map maps one or more keys to the specified value.- Specified by:
containsValuein interfaceMap<P,T> - Overrides:
containsValuein classParameterMap<P,T> - Parameters:
value- value whose presence in this parameter-map is to be tested- Returns:
trueif this parameter-map maps one or more keys to the specified value
-
entrySet
Returns aSetview 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:
putin interfaceMap<P,T> - Overrides:
putin 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, ornullif there was no mapping forkey. (Anullreturn can also indicate that the parameter-map previously associatednullwithkey.)
-
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:
putAllin interfaceMap<P,T> - Overrides:
putAllin 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:
removein interfaceMap<P,T> - Overrides:
removein classParameterMap<P,T> - Parameters:
key- key whose mapping is to be removed from the parameter-map- Returns:
- the previous value associated with
key, ornullif there was no mapping forkey. (Anullreturn can also indicate that the parameter-map previously associatednullwithkey.)
-
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-mapsm1andm2, as required by the general contract ofObject.hashCode(). -
equals
Compares the specified object with this parameter-map for equality. Returnstrueif the given object is also a parameter-map and the two parameter-maps represent the same mappings. More formally, two parameter-mapsm1andm2represent the same mappings ifm1.entrySet().equals(m2.entrySet()).- Specified by:
equalsin interfaceMap<P,T> - Overrides:
equalsin classParameterMap<P,T> - Parameters:
obj- object to be compared for equality with this parameter-map- Returns:
trueif 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.
-