Package org.openjdk.jmc.common.unit
Class MutableConstrainedMap<K>
java.lang.Object
org.openjdk.jmc.common.unit.MutableConstrainedMap<K>
- Type Parameters:
K- the type of the keys in the map
- All Implemented Interfaces:
IConstrainedMap<K>,IMutableConstrainedMap<K>
- Direct Known Subclasses:
SimpleConstrainedMap
A mutable extension to
IConstrainedMap. Note that it is the values that can be mutated.
Existing constraints cannot be modified. However, some implementations may allow adding
constraints for keys that currently doesn't have a constraint, and thus no current value.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedMutableConstrainedMap(HashMap<K, Object> values) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddConstraint(K key, IConstraint<?> constraint) Get the mapped value forkey, or null if no value is currently mapped.abstract IConstraint<?>getConstraint(K key) getPersistableString(K key) Get the persistable string of the mapped value forkey, or null if no value is currently mapped.protected IConstraint<?>getSuggestedConstraint(K key) This method will only be called for keys for whichgetConstraint(Object)currently returns null for.keySet()voidMapkeytovalue, if allowed according to either an existingconstraintor an implicit default constraint, if available.<T> voidput(K key, IConstraint<T> constraint, T value) Mapkeytovalue, if allowed according toconstraintand additional restrictions on this map such as a conflictingconstraintbeing in effect for thiskey.voidputPersistedString(K key, String persisted) Mapkeyto the value obtained by parsingpersisted, if allowed according to either an existingconstraintor an implicit default constraint, if available.<T> voidputPersistedString(K key, IConstraint<T> constraint, String persisted) Mapkeyto the value obtained by parsingpersisted, if allowed according toconstraintand additional restrictions on this map such as a conflictingconstraintbeing in effect for thiskey.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openjdk.jmc.common.unit.IConstrainedMap
emptyWithSameConstraints, mutableCopy
-
Field Details
-
values
-
-
Constructor Details
-
MutableConstrainedMap
protected MutableConstrainedMap() -
MutableConstrainedMap
-
-
Method Details
-
keySet
- Specified by:
keySetin interfaceIConstrainedMap<K>- Returns:
- A
setof keys which are known to be valid. That is, those that currently are known to have aconstraint. This includes all keys which currently have a value, but additional keys may be included. In other words,IConstrainedMap.get(Object)may returnnullfor some keys included in this set.
-
get
Description copied from interface:IConstrainedMapGet the mapped value forkey, or null if no value is currently mapped. If this method ever returns a non-null value,IConstrainedMap.getConstraint(Object)for the samekeywill from that point forward return the same matching non-null constraint.- Specified by:
getin interfaceIConstrainedMap<K>- Returns:
- the mapped value or
null
-
getConstraint
Description copied from interface:IConstrainedMap- Specified by:
getConstraintin interfaceIConstrainedMap<K>- Returns:
- a constraint or
null
-
getSuggestedConstraint
This method will only be called for keys for whichgetConstraint(Object)currently returns null for. Thus, it doesn't matter, and is unspecified, what it would return for keys whichgetConstraint(Object)return non-null for, which typically simplifies the implementations. -
getPersistableString
Description copied from interface:IConstrainedMapGet the persistable string of the mapped value forkey, or null if no value is currently mapped. If this method ever returns a non-null value,IConstrainedMap.getConstraint(Object)for the samekeywill from that point forward return the same matching non-null constraint.- Specified by:
getPersistableStringin interfaceIConstrainedMap<K>- Returns:
- a persistable string or
null
-
put
Description copied from interface:IMutableConstrainedMapMapkeytovalue, if allowed according to either an existingconstraintor an implicit default constraint, if available.- Specified by:
putin interfaceIMutableConstrainedMap<K>- Throws:
QuantityConversionException- ifvalueis rejected by the constraint in some other way
-
putPersistedString
Description copied from interface:IMutableConstrainedMapMapkeyto the value obtained by parsingpersisted, if allowed according to either an existingconstraintor an implicit default constraint, if available.- Specified by:
putPersistedStringin interfaceIMutableConstrainedMap<K>- Throws:
QuantityConversionException- ifpersistedis rejected by the constraint in some way
-
put
Description copied from interface:IMutableConstrainedMapMapkeytovalue, if allowed according toconstraintand additional restrictions on this map such as a conflictingconstraintbeing in effect for thiskey.- Specified by:
putin interfaceIMutableConstrainedMap<K>- Throws:
QuantityConversionException- ifvalueis rejected by the constraint in some other way
-
addConstraint
-
putPersistedString
public <T> void putPersistedString(K key, IConstraint<T> constraint, String persisted) throws QuantityConversionException Description copied from interface:IMutableConstrainedMapMapkeyto the value obtained by parsingpersisted, if allowed according toconstraintand additional restrictions on this map such as a conflictingconstraintbeing in effect for thiskey.- Specified by:
putPersistedStringin interfaceIMutableConstrainedMap<K>- Throws:
QuantityConversionException- ifpersistedis rejected by the constraint in some other way
-