public class PropertyMap extends Properties
When this is cloned it will deep copy not only the model object map, but also each clonable member inside the map.
Subclassing is supported, a hook can be implemented to provide conditional inclusion in the map. By default - all properties are accepted, so set is never propagated.
This class is not multithread safe.
Modifier and Type | Field and Description |
---|---|
private Map<CompoundName,Object> |
properties
The properties of this
|
Constructor and Description |
---|
PropertyMap() |
Modifier and Type | Method and Description |
---|---|
PropertyMap |
clone()
Clones this instance and recursively all chained instance.
|
Object |
get(CompoundName name,
Map<String,String> context,
Properties substitution)
Gets a named value which (if necessary) is resolved using a property context.
|
Map<String,Object> |
listProperties(CompoundName path,
Map<String,String> context,
Properties substitution)
Returns a snapshot of all properties of this having a given path prefix
|
void |
set(CompoundName name,
Object value,
Map<String,String> context)
Sets a value to the first chained instance which accepts it.
|
protected boolean |
shouldSet(CompoundName name,
Object value)
Return true if this value should be set in this map, false if the set should be propagated instead
This default implementation always returns true.
|
asBoolean, asDouble, asInteger, asLong, asString, chain, chained, clone, cloneMap, get, get, get, get, get, get, get, getBoolean, getBoolean, getBoolean, getBoolean, getDouble, getDouble, getDouble, getDouble, getInstance, getInteger, getInteger, getInteger, getInteger, getLong, getLong, getLong, getLong, getString, getString, getString, getString, listProperties, listProperties, listProperties, listProperties, listProperties, listProperties, listProperties, set, set, set
private Map<CompoundName,Object> properties
public void set(CompoundName name, Object value, Map<String,String> context)
Properties
This default implementation forwards to the chained instance or throws a RuntimeException if there is not chained instance.
set
in class Properties
name
- the name of the valuevalue
- the value to set. Setting a name to null explicitly is legal.context
- the context used to resolve where the values should be set, or null if noneprotected boolean shouldSet(CompoundName name, Object value)
public Object get(CompoundName name, Map<String,String> context, Properties substitution)
Properties
get
in class Properties
name
- the name of the property to returncontext
- the variant resolution context, or null if nonesubstitution
- the properties used to substitute in these properties, or null if nonepublic PropertyMap clone()
Properties
clone
in class Properties
public Map<String,Object> listProperties(CompoundName path, Map<String,String> context, Properties substitution)
Properties
Some sources of properties may not be list-able (e.g those using reflection) and will not be included in this snapshot.
listProperties
in class Properties
path
- the prefix (up to a ".") of the properties to return, or null or the empty string to return all propertiescontext
- the context used to resolve the properties, or null if nonesubstitution
- the properties which will be used to do string substitution in the values added to the mapCopyright © 2018. All rights reserved.