K - the type of the keys in the mappublic abstract class MutableConstrainedMap<K> extends java.lang.Object implements IMutableConstrainedMap<K>
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.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<K,java.lang.Object> |
values |
| Modifier | Constructor and Description |
|---|---|
protected |
MutableConstrainedMap() |
protected |
MutableConstrainedMap(java.util.HashMap<K,java.lang.Object> values) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addConstraint(K key,
IConstraint<?> constraint) |
java.lang.Object |
get(K key)
Get the mapped value for
key, or null if no value is currently mapped. |
abstract IConstraint<?> |
getConstraint(K key)
|
private <T> java.lang.String |
getPersistableString(IConstraint<T> constraint,
java.lang.Object value) |
java.lang.String |
getPersistableString(K key)
Get the persistable string of the mapped value for
key, or null if no value is
currently mapped. |
protected IConstraint<?> |
getSuggestedConstraint(K key)
This method will only be called for keys for which
getConstraint(Object) currently
returns null for. |
java.util.Set<K> |
keySet() |
<T> void |
put(K key,
IConstraint<T> constraint,
T value)
Map
key to value, if allowed according to constraint and additional
restrictions on this map such as a conflicting constraint being in effect
for this key. |
void |
put(K key,
java.lang.Object value)
Map
key to value, if allowed according to either an existing
constraint or an implicit default constraint, if available. |
<T> void |
putPersistedString(K key,
IConstraint<T> constraint,
java.lang.String persisted)
Map
key to the value obtained by parsing persisted, if allowed according to
constraint and additional restrictions on this map such as a conflicting
constraint being in effect for this key. |
void |
putPersistedString(K key,
java.lang.String persisted)
Map
key to the value obtained by parsing persisted, if allowed according to
either an existing constraint or an implicit default constraint, if
available. |
private <T> void |
validate(IConstraint<T> constraint,
java.lang.Object value) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitemptyWithSameConstraints, mutableCopyprotected final java.util.Map<K,java.lang.Object> values
protected MutableConstrainedMap()
protected MutableConstrainedMap(java.util.HashMap<K,java.lang.Object> values)
public java.util.Set<K> keySet()
keySet in interface IConstrainedMap<K>set of keys which are known to be valid. That is, those that currently
are known to have a constraint. This includes all keys which
currently have a value, but additional keys may be included. In other words,
IConstrainedMap.get(Object) may return null for some keys included in this set.public java.lang.Object get(K key)
IConstrainedMapkey, or null if no value is currently mapped. If this method
ever returns a non-null value, IConstrainedMap.getConstraint(Object) for the same key will
from that point forward return the same matching non-null constraint.get in interface IConstrainedMap<K>nullpublic abstract IConstraint<?> getConstraint(K key)
IConstrainedMapgetConstraint in interface IConstrainedMap<K>nullprotected IConstraint<?> getSuggestedConstraint(K key)
getConstraint(Object) currently
returns null for. Thus, it doesn't matter, and is unspecified, what it would return for keys
which getConstraint(Object) return non-null for, which typically simplifies the
implementations.public java.lang.String getPersistableString(K key)
IConstrainedMapkey, or null if no value is
currently mapped. If this method ever returns a non-null value,
IConstrainedMap.getConstraint(Object) for the same key will from that point forward return
the same matching non-null constraint.getPersistableString in interface IConstrainedMap<K>nullprivate <T> java.lang.String getPersistableString(IConstraint<T> constraint, java.lang.Object value) throws QuantityConversionException
QuantityConversionExceptionprivate <T> void validate(IConstraint<T> constraint, java.lang.Object value) throws QuantityConversionException
QuantityConversionExceptionpublic void put(K key, java.lang.Object value) throws QuantityConversionException
IMutableConstrainedMapkey to value, if allowed according to either an existing
constraint or an implicit default constraint, if available.put in interface IMutableConstrainedMap<K>QuantityConversionException - if value is rejected by the constraint in some other waypublic void putPersistedString(K key, java.lang.String persisted) throws QuantityConversionException
IMutableConstrainedMapkey to the value obtained by parsing persisted, if allowed according to
either an existing constraint or an implicit default constraint, if
available.putPersistedString in interface IMutableConstrainedMap<K>QuantityConversionException - if persisted is rejected by the constraint in some waypublic <T> void put(K key, IConstraint<T> constraint, T value) throws QuantityConversionException
IMutableConstrainedMapkey to value, if allowed according to constraint and additional
restrictions on this map such as a conflicting constraint being in effect
for this key.put in interface IMutableConstrainedMap<K>QuantityConversionException - if value is rejected by the constraint in some other wayprotected void addConstraint(K key, IConstraint<?> constraint)
public <T> void putPersistedString(K key, IConstraint<T> constraint, java.lang.String persisted) throws QuantityConversionException
IMutableConstrainedMapkey to the value obtained by parsing persisted, if allowed according to
constraint and additional restrictions on this map such as a conflicting
constraint being in effect for this key.putPersistedString in interface IMutableConstrainedMap<K>QuantityConversionException - if persisted is rejected by the constraint in some other way