public class PrefixedDynamicProperties extends Object implements DynamicProperties, Serializable
DynamicProperties
the prefix
is dynamically added and removed so that the prefixing is not visible when using the DynamicProperties
interface.
The methods *PrefixedProperty() allow to access the prefixed property key/values pairs directly.
Constructor and Description |
---|
PrefixedDynamicProperties(String prefix) |
PrefixedDynamicProperties(String prefix,
int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
asMap() |
DynamicProperties |
createFrom(Map<String,Object> map)
Creates a new instance with the properties set from the given map with
DynamicProperties.setPropertiesFrom(Map) |
boolean |
equals(Object obj) |
Object |
getPrefixedProperty(String key) |
Set<String> |
getPrefixedPropertyKeys() |
Object |
getProperty(String key) |
Object |
getProperty(String key,
Object defaultValue) |
Iterable<String> |
getPropertyKeys()
Returns all keys
|
int |
hashCode() |
boolean |
hasPrefixedProperty(String key) |
boolean |
hasProperty(String key) |
boolean |
isPrefixedKey(String key) |
Object |
removeProperty(String key)
Removes the property with the given key
|
void |
setPrefixedProperty(String key,
Object value) |
void |
setPropertiesFrom(Map<String,Object> propertiesMap)
Sets a property for all key/value pairs in the given map
|
void |
setProperty(String key,
Object value)
Set the value of the property with the given key to the given value and overwrites it when such a property
already exists.
|
boolean |
setPropertyIfPrefixed(String key,
Object value)
Set the property with the given key only if the key is prefixed.
|
protected final transient String prefix
public PrefixedDynamicProperties(String prefix)
prefix
- the prefix to be added internally to the keyspublic PrefixedDynamicProperties(String prefix, int initialCapacity)
prefix
- the prefix to be added internally to the keysinitialCapacity
- the initialCapacity of the internal map that holds the propertiespublic boolean hasProperty(String key)
hasProperty
in interface DynamicProperties
key
- the key to be checkedpublic Object getProperty(String key)
getProperty
in interface DynamicProperties
key
- key of the property to getDynamicProperties.hasProperty(java.lang.String)
returns falsepublic Object getProperty(String key, Object defaultValue)
getProperty
in interface DynamicProperties
key
- key of the property to getdefaultValue
- the default value to return if no property with the given key existsDynamicProperties.hasProperty(java.lang.String)
returns falsepublic void setProperty(String key, Object value)
DynamicProperties
setProperty
in interface DynamicProperties
key
- key of the propertyvalue
- value of the propertypublic Object removeProperty(String key)
DynamicProperties
removeProperty
in interface DynamicProperties
DynamicProperties.hasProperty(java.lang.String)
returns
falsepublic Iterable<String> getPropertyKeys()
DynamicProperties
getPropertyKeys
in interface DynamicProperties
public void setPropertiesFrom(Map<String,Object> propertiesMap)
DynamicProperties
setPropertiesFrom
in interface DynamicProperties
propertiesMap
- that contains the key/value pairs to setpublic DynamicProperties createFrom(Map<String,Object> map)
DynamicProperties
DynamicProperties.setPropertiesFrom(Map)
createFrom
in interface DynamicProperties
map
- that contains the key/value pairs to setpublic Map<String,Object> asMap()
asMap
in interface DynamicProperties
public boolean setPropertyIfPrefixed(String key, Object value)
key
- key of the propertyvalue
- valuepublic boolean isPrefixedKey(String key)
public boolean hasPrefixedProperty(String key)
Copyright © 2011-2013-2014 Pivotal. All Rights Reserved.