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>
public class SimpleConstrainedMap<K> extends MutableConstrainedMap<K>
Simple constrained map that allows constraints to be added, and an optional fallback constraint.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<K,IConstraint<?>>constraintsprotected IConstraint<?>fallback-
Fields inherited from class org.openjdk.jmc.common.unit.MutableConstrainedMap
values
-
-
Constructor Summary
Constructors Modifier Constructor Description SimpleConstrainedMap()SimpleConstrainedMap(Map<K,IConstraint<?>> constraints, IConstraint<?> fallback)protectedSimpleConstrainedMap(Map<K,IConstraint<?>> constraints, IConstraint<?> fallback, Map<K,Object> values)SimpleConstrainedMap(IConstraint<?> fallback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddConstraint(K key, IConstraint<?> constraint)IMutableConstrainedMap<K>emptyWithSameConstraints()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.IMutableConstrainedMap<K>mutableCopy()-
Methods inherited from class org.openjdk.jmc.common.unit.MutableConstrainedMap
get, getPersistableString, keySet, put, put, putPersistedString, putPersistedString
-
-
-
-
Field Detail
-
constraints
protected final Map<K,IConstraint<?>> constraints
-
fallback
protected final IConstraint<?> fallback
-
-
Constructor Detail
-
SimpleConstrainedMap
public SimpleConstrainedMap()
-
SimpleConstrainedMap
public SimpleConstrainedMap(IConstraint<?> fallback)
-
SimpleConstrainedMap
public SimpleConstrainedMap(Map<K,IConstraint<?>> constraints, IConstraint<?> fallback)
-
SimpleConstrainedMap
protected SimpleConstrainedMap(Map<K,IConstraint<?>> constraints, IConstraint<?> fallback, Map<K,Object> values)
-
-
Method Detail
-
getConstraint
public IConstraint<?> getConstraint(K key)
Description copied from interface:IConstrainedMap- Specified by:
getConstraintin interfaceIConstrainedMap<K>- Specified by:
getConstraintin classMutableConstrainedMap<K>- Returns:
- a constraint or
null
-
getSuggestedConstraint
protected IConstraint<?> getSuggestedConstraint(K key)
Description copied from class:MutableConstrainedMapThis 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:
getSuggestedConstraintin classMutableConstrainedMap<K>
-
addConstraint
protected void addConstraint(K key, IConstraint<?> constraint)
- Overrides:
addConstraintin classMutableConstrainedMap<K>
-
emptyWithSameConstraints
public IMutableConstrainedMap<K> emptyWithSameConstraints()
Description copied from interface:IConstrainedMapCreate an emptymutablemap, with the same initial constraints as thismap. It might be possible to addconstraintsto the created map, depending on the restrictions built into this map.
-
mutableCopy
public IMutableConstrainedMap<K> mutableCopy()
Description copied from interface:IConstrainedMapCreate amutablecopy of thismap, containing the same initial values as this map. It might be possible to addconstraintsto the copy, depending on the restrictions built into this map.
-
-