|
||||||||||
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
@ThreadSafe public abstract class AbstractConfigurationProperties
Abstract implementation of the ConfigurationProperties
interface.
Constructor Summary | |
---|---|
protected |
AbstractConfigurationProperties() Constructor for serializable subclasses. |
protected |
AbstractConfigurationProperties(ConfigurationKey<?> key, de.smartics.properties.api.core.domain.PropertyDescriptorRegistry registry, de.smartics.properties.api.core.security.PropertyValueSecurity decrypter) Default constructor. |
Method Summary | ||
---|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener) Adds the given listener to track any property changes. |
|
void |
addPropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name, PropertyChangeListener listener) Adds the given listener as a listener to the given property. |
|
protected void |
firePropertyChange(String name, String oldValue, String newValue) Fires the property change event. |
|
de.smartics.properties.api.core.domain.PropertiesContext |
getContext(Class<?> declaringType) Returns the properties context for the declaring type. |
|
de.smartics.properties.api.core.domain.PropertyContext |
getContext(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) Returns the properties context the property described by the given descriptor is part of. |
|
ConfigurationKey<?> |
getKey() Returns the key of the configuration. |
|
|
getProperties(Class<T> propertiesInterface) Returns a implementation of the given interface that has access to the property keys, the property descriptors and the properties itself, when they are declared in the given interface. |
|
|
getProperties(Class<T> propertiesInterface, SerializableConfigurationProperties configuration) Returns a implementation of the given interface that has access to the property keys, the property descriptors and the properties itself, when they are declared in the given interface. |
|
DescribedProperty |
getProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) Returns the property for the given descriptor. |
|
DescribedProperty |
getProperty(de.smartics.properties.api.core.domain.PropertyKey key) Returns the property for the given key. |
|
DescribedProperty |
getProperty(String key) Returns the property for the given key. |
|
DescribedProperty |
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. |
|
protected de.smartics.properties.api.core.domain.PropertyDescriptor |
getPropertyDescriptor(String key) Returns the property descriptor for a given key. |
|
Object |
getPropertyValue(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) Returns the property value for the given descriptor. |
|
Object |
getPropertyValue(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue) Returns the property value for the given descriptor, allowing to transparently provide a default value to be returned in case the property has not been set. |
|
Object |
getPropertyValue(de.smartics.properties.api.core.domain.PropertyKey key) Returns the property value for the given key. |
|
Object |
getPropertyValue(String key) Returns the property value for the given key. |
|
Object |
getPropertyValue(String key, Object defaultValue) Returns the property value for the given key, allowing to transparently provide a default value to be returned in case the property has not been set. |
|
String |
getPropertyValueAsString(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) Returns the property string value for the given descriptor. |
|
String |
getPropertyValueAsString(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue) Returns the property string value for the given descriptor. |
|
String |
getPropertyValueAsString(String key) Returns the property string value for the given key. |
|
String |
getPropertyValueAsString(String key, Object defaultValue) Returns the property string value for the given key. |
|
de.smartics.properties.api.core.security.PropertyValueSecurity |
getPropertyValueSecurity() Returns the property value security helper to en- and decrypt property values. |
|
de.smartics.properties.api.core.domain.PropertyDescriptorRegistry |
getRegistry() Returns the registry to resolve property descriptors. |
|
ValidatedProperty |
getValidatedProperty(de.smartics.properties.api.core.domain.PropertyKey key, Object defaultValue) Returns the validated property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set. |
|
ValidatedProperty |
getValidatedProperty(String key, Object defaultValue) Returns the validated property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set. |
|
void |
removePropertyChangeListener(PropertyChangeListener listener) Removes the given listener to stop tracking property changes. |
|
void |
removePropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name, PropertyChangeListener listener) Removes the given listener as a listener to the given property. |
|
protected Object |
resolveAndConvert(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object value, Object defaultValue) Resolves and converts the given value. |
|
protected Object |
resolveAndConvertAndValidate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue, Object value) Resolves, converts and validates the given value. |
|
ConfigurationProperties |
toRepresentative() Creates an representative of this configuration. |
|
String |
toString() Returns the string representation of the object. |
|
void |
validate() Validates all properties in the given configuration in a non-lenient fashion. |
|
void |
validate(Class<?>... groups) Validates all properties in the given configuration and groups in a non-lenient fashion. |
|
void |
validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object value, Class<?>... ifInOneOfTheseGroups) Validates the given value for the given property. |
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.ConfigurationProperties |
---|
getProperty, getPropertyAsType, getValidatedProperty, isInAdminMode, toSerializable, validate, validate, validate |
Constructor Detail |
---|
protected AbstractConfigurationProperties()
protected AbstractConfigurationProperties(ConfigurationKey<?> key, de.smartics.properties.api.core.domain.PropertyDescriptorRegistry registry, de.smartics.properties.api.core.security.PropertyValueSecurity decrypter) throws de.smartics.util.lang.NullArgumentException
key
- the key that identifies the configuration.
registry
- the registry to resolve property descriptors.
decrypter
- the helper to decrypt secured property values.
de.smartics.util.lang.NullArgumentException
- if
key
,
registry
or
decrypter
is
null
.
Method Detail |
---|
public final ConfigurationKey<?> getKey()
ConfigurationProperties
getKey
in interface
ConfigurationProperties
null
.
public final de.smartics.properties.api.core.domain.PropertyContext getContext(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) throws NullPointerException
ConfigurationProperties
getContext
in interface
ConfigurationProperties
descriptor
- the descriptor of the property whose context is requested.
NullPointerException
- if
descriptor
is
null
.
public final de.smartics.properties.api.core.domain.PropertiesContext getContext(Class<?> declaringType) throws NullPointerException
ConfigurationProperties
PropertySet
annotation. The context provides information about the properties of that set.
getContext
in interface
ConfigurationProperties
declaringType
- the type that declares the properties whose context is requested.
NullPointerException
- if
declaringType
is
null
.
public final de.smartics.properties.api.core.domain.PropertyDescriptorRegistry getRegistry()
public final de.smartics.properties.api.core.security.PropertyValueSecurity getPropertyValueSecurity()
public final DescribedProperty getProperty(String key) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
key
- the unique key of the property.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
public DescribedProperty getProperty(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
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 final DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyKey key) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
key
- the unique key of the property.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
public final DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
descriptor
- the descriptor containing the unique key of the property.
UnknownPropertyException
- if the key of the
descriptor
is not known.
IllegalArgumentException
public final <T> T getProperties(Class<T> propertiesInterface)
ConfigurationProperties
PropertySet
annotation.
getProperties
in interface
ConfigurationProperties
T
- type variable to enable a type save return value.
propertiesInterface
- a
PropertySet
annotated interface for which a implementation to access the property keys, descriptors and values is requested.
public final <T> T getProperties(Class<T> propertiesInterface, SerializableConfigurationProperties configuration)
ConfigurationPropertiesSpi
PropertySet
annotation.
Allows to pass in a configuration to consult.
getProperties
in interface
ConfigurationPropertiesSpi
T
- type variable to enable a type save return value.
propertiesInterface
- a
PropertySet
annotated interface for which a implementation to access the property keys, descriptors and values is requested.
configuration
- the access to the properties. Must not be
null
.
public final Object getPropertyValue(String key) throws IllegalArgumentException, UnknownPropertyException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
getPropertyValue
in interface
ConfigurationProperties
key
- the key to the property.
null
is returned in cause of an optional property being not set.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
public final Object getPropertyValue(de.smartics.properties.api.core.domain.PropertyKey key) throws IllegalArgumentException, UnknownPropertyException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
getPropertyValue
in interface
ConfigurationProperties
key
- the key to the property.
null
is returned in cause of an optional property being not set.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
public final Object getPropertyValue(String key, Object defaultValue) throws de.smartics.util.lang.NullArgumentException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
getPropertyValue
in interface
ConfigurationProperties
key
- the key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
is returned in cause of an optional property being not set.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.util.lang.NullArgumentException
public final String getPropertyValueAsString(String key) throws de.smartics.util.lang.NullArgumentException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
String
, the
Object.toString()
method is called to create the string representation of the value.
null
is always returned as
null
(not as the String "null").
getPropertyValueAsString
in interface
ConfigurationProperties
key
- the key to the property.
null
is returned in cause of an optional property being not set.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.util.lang.NullArgumentException
public final Object getPropertyValue(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue) throws NullPointerException, de.smartics.properties.api.core.domain.PropertyValueConversionException, de.smartics.properties.api.core.domain.PropertyValidationException, UnknownPropertyException
ConfigurationProperties
getPropertyValue
in interface
ConfigurationProperties
descriptor
- the key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
is returned in cause of an optional property being not set.
NullPointerException
- if
descriptor
is
null
.
de.smartics.properties.api.core.domain.PropertyValueConversionException
- if conversion fails.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
UnknownPropertyException
- if the requested property is not known to the system.
public final String getPropertyValueAsString(String key, Object defaultValue) throws de.smartics.util.lang.NullArgumentException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
String
, the
Object.toString()
method is called to create the string representation of the value.
null
is always returned as
null
(not as the String "null").
getPropertyValueAsString
in interface
ConfigurationProperties
key
- the key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
is returned in cause of an optional property being not set.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.util.lang.NullArgumentException
public final Object getPropertyValue(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) throws de.smartics.util.lang.NullArgumentException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
getPropertyValue
in interface
ConfigurationProperties
descriptor
- the key to the property.
null
is returned in cause of an optional property being not set.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.util.lang.NullArgumentException
public final String getPropertyValueAsString(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) throws de.smartics.util.lang.NullArgumentException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
String
, the
Object.toString()
method is called to create the string representation of the value.
null
is always returned as
null
(not as the String "null").
getPropertyValueAsString
in interface
ConfigurationProperties
descriptor
- the key to the property.
null
is returned in cause of an optional property being not set.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.util.lang.NullArgumentException
public final String getPropertyValueAsString(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue) throws de.smartics.util.lang.NullArgumentException, de.smartics.properties.api.core.domain.PropertyValidationException
ConfigurationProperties
String
, the
Object.toString()
method is called to create the string representation of the value.
null
is always returned as
null
(not as the String "null").
getPropertyValueAsString
in interface
ConfigurationProperties
descriptor
- the key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
is returned in cause of an optional property being not set.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.util.lang.NullArgumentException
public final ValidatedProperty getValidatedProperty(de.smartics.properties.api.core.domain.PropertyKey key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, de.smartics.properties.api.core.domain.PropertyValidationException, de.smartics.properties.api.core.security.SecurityException
ConfigurationProperties
getValidatedProperty
in interface
ConfigurationProperties
key
- the key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
, although the value / validated value of the returned property may be
null
.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.properties.api.core.security.SecurityException
- on any problem decrypting an encrypted value.
public final ValidatedProperty getValidatedProperty(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, de.smartics.properties.api.core.domain.PropertyValidationException, de.smartics.properties.api.core.security.SecurityException
ConfigurationProperties
getValidatedProperty
in interface
ConfigurationProperties
key
- the key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
, although the value / validated value of the returned property may be
null
.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property is invalid according to its constraints.
de.smartics.properties.api.core.security.SecurityException
- on any problem decrypting an encrypted value.
protected final de.smartics.properties.api.core.domain.PropertyDescriptor getPropertyDescriptor(String key) throws de.smartics.util.lang.BlankArgumentException, de.smartics.properties.api.core.domain.PropertyValidationException
key
- the key for which the property descriptor is needed.
de.smartics.util.lang.BlankArgumentException
- when the key is blank.
de.smartics.properties.api.core.domain.PropertyValidationException
- when the configuration is invalid.
protected final Object resolveAndConvertAndValidate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue, Object value) throws de.smartics.properties.api.core.domain.PropertyValueConversionException, de.smartics.properties.api.core.domain.PropertyValidationException, de.smartics.properties.api.core.security.SecurityException
descriptor
- the property descriptor.
defaultValue
- the default value to use if
value
is
null
and there is no default expression.
value
- the value to resolve, convert and validate.
de.smartics.properties.api.core.domain.PropertyValueConversionException
- if the value cannot be converted from
String
to the target type. If the configuration is set to admin mode, the unresolved
value
will be returned. In this case the type is not of the target type as described by the descriptor.
de.smartics.properties.api.core.domain.PropertyValidationException
- if at least on constraint is not met.
de.smartics.properties.api.core.security.SecurityException
- on any problem decrypting an encrypted value.
public void validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object value, Class<?>... ifInOneOfTheseGroups)
descriptor
- the descriptor to the property to use for validation.
value
- the property value to validate.
ifInOneOfTheseGroups
- the validation groups to consider in the validation process. The groups will be validated in the given order. As soon as a validation group fails, the validation process is aborted without checking the not yet processed groups.
protected final Object resolveAndConvert(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object value, Object defaultValue) throws de.smartics.properties.api.core.domain.PropertyValueResolveException, de.smartics.properties.api.core.domain.PropertyValueConversionException, de.smartics.properties.api.core.security.SecurityException
descriptor
- the property descriptor.
value
- the value to resolve and convert.
defaultValue
- the default value to use if
value
is
null
and there is no default expression.
de.smartics.properties.api.core.domain.PropertyValueResolveException
- if the value cannot be resolved.
de.smartics.properties.api.core.domain.PropertyValueConversionException
- if the value cannot be converted from
String
to the target type.
de.smartics.properties.api.core.security.SecurityException
- on any problem decrypting an encrypted value.
public final void validate() throws ConfigurationValidationException
ConfigurationProperties
validate
in interface
ConfigurationProperties
ConfigurationValidationException
- if the configuration contains properties that do not meet the required constraints.
public final void validate(Class<?>... groups) throws ConfigurationValidationException
ConfigurationProperties
validate
in interface
ConfigurationProperties
groups
- the validation groups to consider in the validation process. The groups will be validated in the given order. As soon as a validation group fails, the validation process is aborted without checking the not yet processed groups.
ConfigurationValidationException
- if the configuration contains properties that do not meet the required constraints.
public final void addPropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name, PropertyChangeListener listener) throws NullPointerException
ConfigurationProperties
addPropertyChangeListener
in interface
ConfigurationProperties
name
- the name of the property to track changes.
listener
- the listener to add.
NullPointerException
- if
name
or
listener
is
null
.
public final void removePropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name, PropertyChangeListener listener) throws NullPointerException
ConfigurationProperties
removePropertyChangeListener
in interface
ConfigurationProperties
name
- the name of the property to stop tracking changes.
listener
- the listener to remove.
NullPointerException
- if
name
or
listener
is
null
.
public final void addPropertyChangeListener(PropertyChangeListener listener) throws NullPointerException
ConfigurationProperties
addPropertyChangeListener
in interface
ConfigurationProperties
listener
- the listener to add.
NullPointerException
- if
listener
is
null
.
public final void removePropertyChangeListener(PropertyChangeListener listener) throws NullPointerException
ConfigurationProperties
removePropertyChangeListener
in interface
ConfigurationProperties
listener
- the listener to remove.
NullPointerException
- if
listener
is
null
.
protected final void firePropertyChange(String name, String oldValue, String newValue)
name
- the name of the property.
oldValue
- the old value of the property that has been changed.
newValue
- the new and current value of the property.
public ConfigurationProperties toRepresentative()
ConfigurationProperties
toRepresentative
in interface
ConfigurationProperties
public String toString()
toString
in class
Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |