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
 
 public abstract class MutableConstrainedMap<K> extends Object implements IMutableConstrainedMap<K> A mutable extension toIConstrainedMap. 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.
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedMutableConstrainedMap()protectedMutableConstrainedMap(HashMap<K,Object> values)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddConstraint(K key, IConstraint<?> constraint)Objectget(K key)Get the mapped value forkey, or null if no value is currently mapped.abstract IConstraint<?>getConstraint(K key)StringgetPersistableString(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.Set<K>keySet()voidput(K key, Object value)Mapkeytovalue, 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.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.openjdk.jmc.common.unit.IConstrainedMapemptyWithSameConstraints, mutableCopy
 
- 
 
- 
- 
- 
Method Detail- 
keySetpublic Set<K> keySet() - Specified by:
- keySetin interface- IConstrainedMap<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.
 
 - 
getpublic Object get(K key) 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 interface- IConstrainedMap<K>
- Returns:
- the mapped value or null
 
 - 
getConstraintpublic abstract IConstraint<?> getConstraint(K key) Description copied from interface:IConstrainedMap- Specified by:
- getConstraintin interface- IConstrainedMap<K>
- Returns:
- a constraint or null
 
 - 
getSuggestedConstraintprotected IConstraint<?> getSuggestedConstraint(K key) 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.
 - 
getPersistableStringpublic String getPersistableString(K key) 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 interface- IConstrainedMap<K>
- Returns:
- a persistable string or null
 
 - 
putpublic void put(K key, Object value) throws QuantityConversionException Description copied from interface:IMutableConstrainedMapMapkeytovalue, if allowed according to either an existingconstraintor an implicit default constraint, if available.- Specified by:
- putin interface- IMutableConstrainedMap<K>
- Throws:
- QuantityConversionException- if- valueis rejected by the constraint in some other way
 
 - 
putPersistedStringpublic void putPersistedString(K key, String persisted) throws QuantityConversionException 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 interface- IMutableConstrainedMap<K>
- Throws:
- QuantityConversionException- if- persistedis rejected by the constraint in some way
 
 - 
putpublic <T> void put(K key, IConstraint<T> constraint, T value) throws QuantityConversionException 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 interface- IMutableConstrainedMap<K>
- Throws:
- QuantityConversionException- if- valueis rejected by the constraint in some other way
 
 - 
addConstraintprotected void addConstraint(K key, IConstraint<?> constraint) 
 - 
putPersistedStringpublic <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 interface- IMutableConstrainedMap<K>
- Throws:
- QuantityConversionException- if- persistedis rejected by the constraint in some other way
 
 
- 
 
-