public class CompositeValueMap extends Object implements ValueMap
ValueMap
based on two ValueMap
s:
- One containing the properties
- Another one containing the defaults to use in case the properties map
does not contain the values.
In case you would like to avoid duplicating properties on multiple resources,
you can use a CompositeValueMap
to get a concatenated map of
properties.Constructor and Description |
---|
CompositeValueMap(ValueMap properties,
ValueMap defaults)
Constructor
|
CompositeValueMap(ValueMap properties,
ValueMap defaults,
boolean merge)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<String,Object>> |
entrySet() |
Object |
get(Object key) |
<T> T |
get(String key,
Class<T> type)
Get a named property and convert it into the given type.
|
<T> T |
get(String key,
T defaultValue)
Get a named property and convert it into the given type.
|
boolean |
isEmpty() |
Set<String> |
keySet() |
Object |
put(String aKey,
Object value) |
void |
putAll(Map<? extends String,?> properties) |
Object |
remove(Object key) |
int |
size() |
Collection<Object> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
public CompositeValueMap(ValueMap properties, ValueMap defaults, boolean merge)
properties
- The ValueMap
to read fromdefaults
- The default ValueMap
to use as fallbackmerge
- Merge flag
- If true
, getting a key would return the
current property map's value (if available), even if the
corresponding default does not exist.
- If false
, getting a key would return
null
if the corresponding default does not
existpublic <T> T get(String key, Class<T> type)
null
in this
case.public <T> T get(String key, T defaultValue)
get
in interface ValueMap
key
- The name of the propertydefaultValue
- The default value to use if the named property does
not exist or cannot be converted to the requested type. The
default value is also used to define the type to convert the
value to. If this is null
any existing property is
not converted.public boolean containsKey(Object key)
containsKey
in interface Map<String,Object>
public boolean containsValue(Object value)
containsValue
in interface Map<String,Object>
Copyright © 2014 The Apache Software Foundation. All rights reserved.