Package org.openjdk.jmc.common.unit
Class SimpleConstrainedMap<K>
java.lang.Object
org.openjdk.jmc.common.unit.MutableConstrainedMap<K>
org.openjdk.jmc.common.unit.SimpleConstrainedMap<K>
- Type Parameters:
K
- the type of the keys in the map
- All Implemented Interfaces:
IConstrainedMap<K>
,IMutableConstrainedMap<K>
Simple constrained map that allows constraints to be added, and an optional fallback constraint.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<K,
IConstraint<?>> protected final IConstraint<?>
Fields inherited from class org.openjdk.jmc.common.unit.MutableConstrainedMap
values
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSimpleConstrainedMap
(Map<K, IConstraint<?>> constraints, IConstraint<?> fallback) protected
SimpleConstrainedMap
(Map<K, IConstraint<?>> constraints, IConstraint<?> fallback, Map<K, Object> values) SimpleConstrainedMap
(IConstraint<?> fallback) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addConstraint
(K key, IConstraint<?> constraint) IConstraint<?>
getConstraint
(K key) protected IConstraint<?>
getSuggestedConstraint
(K key) This method will only be called for keys for whichMutableConstrainedMap.getConstraint(Object)
currently returns null for.Methods inherited from class org.openjdk.jmc.common.unit.MutableConstrainedMap
get, getPersistableString, keySet, put, put, putPersistedString, putPersistedString
-
Field Details
-
constraints
-
fallback
-
-
Constructor Details
-
SimpleConstrainedMap
public SimpleConstrainedMap() -
SimpleConstrainedMap
-
SimpleConstrainedMap
-
SimpleConstrainedMap
protected SimpleConstrainedMap(Map<K, IConstraint<?>> constraints, IConstraint<?> fallback, Map<K, Object> values)
-
-
Method Details
-
getConstraint
Description copied from interface:IConstrainedMap
- Specified by:
getConstraint
in interfaceIConstrainedMap<K>
- Specified by:
getConstraint
in classMutableConstrainedMap<K>
- Returns:
- a constraint or
null
-
getSuggestedConstraint
Description copied from class:MutableConstrainedMap
This method will only be called for keys for whichMutableConstrainedMap.getConstraint(Object)
currently returns null for. Thus, it doesn't matter, and is unspecified, what it would return for keys whichMutableConstrainedMap.getConstraint(Object)
return non-null for, which typically simplifies the implementations.- Overrides:
getSuggestedConstraint
in classMutableConstrainedMap<K>
-
addConstraint
- Overrides:
addConstraint
in classMutableConstrainedMap<K>
-
emptyWithSameConstraints
Description copied from interface:IConstrainedMap
Create an emptymutable
map, with the same initial constraints as thismap
. It might be possible to addconstraints
to the created map, depending on the restrictions built into this map. -
mutableCopy
Description copied from interface:IConstrainedMap
Create amutable
copy of thismap
, containing the same initial values as this map. It might be possible to addconstraints
to the copy, depending on the restrictions built into this map.
-