|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.smartics.properties.spi.config.support.AbstractConfigurationProperties de.smartics.properties.spi.config.support.ConfigurationPropertiesManagementWithDefaults
public final class ConfigurationPropertiesManagementWithDefaults
A configuration properties instance that contains the main configuration properties, which matches the key, and all the defaults that have a partial representation of the key.
This implementation is thread-safe as long as the passed in instances of ConfigurationPropertiesManagement
are thread-safe.
Constructor Summary | |
---|---|
ConfigurationPropertiesManagementWithDefaults(List<ConfigurationPropertiesManagement> configurationProperties) Default constructor. |
Method Summary | |
---|---|
ConfigurationPropertiesManagement |
addDefinitions(Properties properties) Adds the given definitions to this configuration. |
void |
addDescriptors(Class<?> declaringType) Adds all property descriptors declared in the given type. |
void |
flush() Signal to flush properties changed in memory to be written to a secondary storage. |
PropertyDescriptor |
getDescriptor(PropertyKey key) Returns the descriptor for the given key. |
PropertyDescriptor |
getDescriptor(String key) Returns the descriptor for the given key. |
List<PropertyDescriptor> |
getMandatoryPropertyDescriptors() Returns the list of mandatory properties. |
Property |
getProperty(PropertyDescriptor descriptor, Object defaultValue) Returns the property for the given descriptor, allowing to transparently provide a default value to be returned in case the property has not been set. |
Property |
getProperty(String key, Object defaultValue) Returns the property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set. |
ResolvedProperty |
getResolvedProperty(PropertyDescriptor descriptor, Object defaultValue) Returns the resolved property for the given descriptor's key, allowing to transparently provide a default value to be returned in case the property has not been set. |
Property |
setProperty(PropertyKey key, String value) Sets the property value for the given key. |
SerializableConfigurationPropertiesManagement |
toSerializable() Creates a serializable variant of this implementation. |
String |
toString() Returns the string representation of the object. |
Property |
unsetProperty(PropertyKey key) Unsets the property value for the given key. |
void |
validate(boolean lenient) Validates all properties in the given configuration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement |
---|
getRegistry |
Methods inherited from interface de.smartics.properties.api.config.domain.ConfigurationProperties |
---|
addPropertyChangeListener, addPropertyChangeListener, getContext, getContext, getKey, getProperties, getProperty, getProperty, getProperty, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getResolvedProperty, getResolvedProperty, removePropertyChangeListener, removePropertyChangeListener, validate |
Constructor Detail |
---|
public ConfigurationPropertiesManagementWithDefaults(List<ConfigurationPropertiesManagement> configurationProperties) throws IllegalArgumentException
configurationProperties
- the list of configuration properties to consult on requests.
IllegalArgumentException
- if
configurationProperties
is
null
or empty.
Method Detail |
---|
public Property getProperty(PropertyDescriptor descriptor, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
descriptor
- the descriptor containing the unique key of the property.
defaultValue
- the default value to use in case no value has been specified.
UnknownPropertyException
- if the key of the
descriptor
is not known.
IllegalArgumentException
public Property getProperty(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
getProperty
in class
AbstractConfigurationProperties
key
- the unique key of the property.
defaultValue
- the default value to use in case no value has been specified.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
public ResolvedProperty getResolvedProperty(PropertyDescriptor descriptor, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, PropertyValidationException
ConfigurationProperties
getResolvedProperty
in interface
ConfigurationProperties
descriptor
- descriptor key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
, although the value / resolved value of the returned property may be
null
.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
PropertyValidationException
- if the property is invalid according to its constraints.
public void validate(boolean lenient) throws ConfigurationValidationException
ConfigurationProperties
validate
in interface
ConfigurationProperties
lenient
- the lenient flag that tells the validation process to handle unknown properties gracefully if set to
true
. If the value is
false
unknown properties are reported as validation failures.
ConfigurationValidationException
- if the configuration contains properties that do not meet the required constraints.
public void flush()
ConfigurationPropertiesManagement
Implementations are not required to only write on a flush. They have to make sure that after the flush is called, all data is transfered to the secondary storage.
flush
in interface
ConfigurationPropertiesManagement
public SerializableConfigurationPropertiesManagement toSerializable()
ConfigurationProperties
toSerializable
in interface
ConfigurationProperties
toSerializable
in interface
ConfigurationPropertiesManagement
ConfigurationPropertiesProxy
,
ConfigurationPropertiesManagementProxy
public ConfigurationPropertiesManagement addDefinitions(Properties properties) throws NullPointerException
ConfigurationPropertiesManagement
addDefinitions
in interface
ConfigurationPropertiesManagement
properties
- the property definitions to add.
NullPointerException
- if
properties
is
null
.
public Property setProperty(PropertyKey key, String value) throws NullPointerException, PropertyValidationException, ReadOnlyPropertyException
This method sets the property in the most defining representative. If the client wants to change a value in a specific defaulting representation by its configuration key, the client has to access this particular instance and set it manually.
setProperty
in interface
ConfigurationPropertiesManagement
key
- the key to the property.
value
- the value to the property.
null
is returned if the property had no value prior to this call.
NullPointerException
- if
key
is
null
.
PropertyValidationException
- if the property value is invalid according to its constraints.
ReadOnlyPropertyException
- if the property to update is read-only.
public Property unsetProperty(PropertyKey key) throws NullPointerException, ReadOnlyPropertyException
This method unsets the property in the most defining representative. If the client wants to change a value in a specific defaulting representation by its configuration key, the client has to access this particular instance and unset it manually.
unsetProperty
in interface
ConfigurationPropertiesManagement
key
- the key to the property.
null
is returned if the property had no value prior to this call.
NullPointerException
- if
key
is
null
.
ReadOnlyPropertyException
- if the property to update is read-only.
public void addDescriptors(Class<?> declaringType) throws DuplicatePropertyDeclarationsException
ConfigurationPropertiesManagement
addDescriptors
in interface
ConfigurationPropertiesManagement
declaringType
- the type that declares the descriptors.
DuplicatePropertyDeclarationsException
- if any of the descriptors declare the same property.
public PropertyDescriptor getDescriptor(String key) throws UnknownPropertyException
ConfigurationPropertiesManagement
getDescriptor
in interface
ConfigurationPropertiesManagement
key
- the of the requested descriptor.
key
.
UnknownPropertyException
- if the property is not known.
public PropertyDescriptor getDescriptor(PropertyKey key) throws UnknownPropertyException
ConfigurationPropertiesManagement
getDescriptor
in interface
ConfigurationPropertiesManagement
key
- the of the requested descriptor.
key
.
UnknownPropertyException
- if the property is not known.
public List<PropertyDescriptor> getMandatoryPropertyDescriptors()
ConfigurationPropertiesManagement
Returns a copy that can be edited.
getMandatoryPropertyDescriptors
in interface
ConfigurationPropertiesManagement
public String toString()
toString
in class
AbstractConfigurationProperties
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |