|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConfigurationProperties
Provides access to all configuration properties for a given application in a given environment.
There are two ways to access property values.
getProperties(Class)
to obtain an implementation of an interface that provides access to the property values through its methods. This is the recommended way to deal with properties.getProperty
methods. This access may be more convenient, if the context deals with property keys that are provided by the user (e.g. from an UI).
de.smartics.properties.api.config
.
Method Summary | ||
---|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener) Adds the given listener to track any property changes. |
|
void |
addPropertyChangeListener(PropertyKey name, PropertyChangeListener listener) Adds the given listener as a listener to the given property. |
|
PropertiesContext |
getContext(Class<?> declaringType) Returns the properties context for the declaring type. |
|
PropertyContext |
getContext(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. |
|
DescribedProperty |
getProperty(PropertyDescriptor descriptor) Returns the property for the given descriptor. |
|
DescribedProperty |
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. |
|
DescribedProperty |
getProperty(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. |
|
Object |
getPropertyAsType(PropertyDescriptor descriptor) Returns the yet not validated property for the given descriptor's key. |
|
Object |
getPropertyValue(PropertyDescriptor descriptor) Returns the property value for the given descriptor. |
|
Object |
getPropertyValue(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(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(PropertyDescriptor descriptor) Returns the property string value for the given descriptor. |
|
String |
getPropertyValueAsString(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. |
|
ValidatedProperty |
getValidatedProperty(PropertyDescriptor descriptor, Object defaultValue) Returns the validated 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. |
|
ValidatedProperty |
getValidatedProperty(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. |
|
boolean |
isInAdminMode() Checks whether or not this configuration is in administration mode. |
|
void |
removePropertyChangeListener(PropertyChangeListener listener) Removes the given listener to stop tracking property changes. |
|
void |
removePropertyChangeListener(PropertyKey name, PropertyChangeListener listener) Removes the given listener as a listener to the given property. |
|
ConfigurationProperties |
toRepresentative() Creates an representative of this configuration. |
|
SerializableConfigurationProperties |
toSerializable() Creates a serializable variant of this implementation. |
|
void |
validate() Validates all properties in the given configuration in a non-lenient fashion. |
|
void |
validate(boolean lenient, Class<?>... groups) Validates all properties in the given configuration. |
|
void |
validate(Class<?>... groups) Validates all properties in the given configuration and groups in a non-lenient fashion. |
|
void |
validate(PropertyDescriptor descriptor, Class<?>... ifInOneOfTheseGroups) Validates the given property in the given configuration. |
|
void |
validate(PropertyDescriptor descriptor, String value, Class<?>... ifInOneOfTheseGroups) Validates the given property in the given configuration. |
Method Detail |
---|
ConfigurationKey<?> getKey()
null
.
PropertiesContext getContext(Class<?> declaringType) throws NullPointerException
PropertySet
annotation. The context provides information about the properties of that set.
declaringType
- the type that declares the properties whose context is requested.
NullPointerException
- if
declaringType
is
null
.
PropertyContext getContext(PropertyDescriptor descriptor) throws NullPointerException
descriptor
- the descriptor of the property whose context is requested.
NullPointerException
- if
descriptor
is
null
.
boolean isInAdminMode()
true
if the configuration is in administration mode,
false
otherwise.
<T> T getProperties(Class<T> propertiesInterface)
PropertySet
annotation.
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.
Object getPropertyValue(PropertyDescriptor descriptor) throws NullPointerException, PropertyValidationException
descriptor
- the key to the property.
null
is returned in cause of an optional property being not set.
NullPointerException
- if
descriptor
is
null
.
PropertyValidationException
- if the property is invalid according to its constraints.
Object getPropertyValue(String key) throws IllegalArgumentException, UnknownPropertyException, PropertyValidationException
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.
PropertyValidationException
- if the property is invalid according to its constraints.
Object getPropertyValue(PropertyKey key) throws IllegalArgumentException, UnknownPropertyException, PropertyValidationException
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.
PropertyValidationException
- if the property is invalid according to its constraints.
Object getPropertyValue(PropertyDescriptor descriptor, Object defaultValue) throws NullPointerException, PropertyValueConversionException, PropertyValidationException, UnknownPropertyException
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
.
PropertyValueConversionException
- if conversion fails.
PropertyValidationException
- if the property is invalid according to its constraints.
UnknownPropertyException
- if the requested property is not known to the system.
Object getPropertyValue(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, PropertyValidationException
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.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
PropertyValidationException
- if the property is invalid according to its constraints.
DescribedProperty getProperty(String key) throws IllegalArgumentException, UnknownPropertyException
key
- the unique key of the property.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
DescribedProperty getProperty(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException
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.
DescribedProperty getProperty(PropertyKey key) throws IllegalArgumentException, UnknownPropertyException
key
- the unique key of the property.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
DescribedProperty getProperty(PropertyDescriptor descriptor) throws NullPointerException, UnknownPropertyException
descriptor
- the descriptor containing the unique key of the property.
NullPointerException
- if
descriptor
is
null
.
UnknownPropertyException
- if the key of the
descriptor
is not known.
DescribedProperty getProperty(PropertyDescriptor descriptor, Object defaultValue) throws NullPointerException, UnknownPropertyException
descriptor
- the descriptor containing the unique key of the property.
defaultValue
- the default value to use in case no value has been specified.
NullPointerException
- if
descriptor
is
null
.
UnknownPropertyException
- if the key of the
descriptor
is not known.
Object getPropertyAsType(PropertyDescriptor descriptor) throws IllegalArgumentException, UnknownPropertyException, PropertyValueConversionException, SecurityException, PropertyRootException
descriptor
- descriptor key to the property.
null
if the property's value is actually unset.
IllegalArgumentException
- if
descriptor
is blank.
UnknownPropertyException
- if
descriptor
is not known.
PropertyValueConversionException
- if the property cannot be converted to its value.
SecurityException
- on any problem decrypting an encrypted value.
PropertyRootException
- on any problem.
ValidatedProperty getValidatedProperty(PropertyDescriptor descriptor, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, PropertyValueConversionException, PropertyValidationException, SecurityException, PropertyRootException
descriptor
- descriptor 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
descriptor
is blank.
UnknownPropertyException
- if
descriptor
is not known.
PropertyValueConversionException
- if the property cannot be converted to its value.
PropertyValidationException
- if the property is invalid according to its constraints.
SecurityException
- on any problem decrypting an encrypted value.
PropertyRootException
- on any problem.
ValidatedProperty getValidatedProperty(PropertyKey key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, PropertyValueConversionException, PropertyValidationException, SecurityException, PropertyRootException
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.
PropertyValueConversionException
- if the property cannot be converted to its value.
PropertyValidationException
- if the property is invalid according to its constraints.
SecurityException
- on any problem decrypting an encrypted value.
PropertyRootException
- on any problem.
ValidatedProperty getValidatedProperty(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, PropertyValueConversionException, PropertyValidationException, SecurityException, PropertyRootException
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.
PropertyValueConversionException
- if the property cannot be converted to its value.
PropertyValidationException
- if the property is invalid according to its constraints.
SecurityException
- on any problem decrypting an encrypted value.
PropertyRootException
- on any problem.
String getPropertyValueAsString(PropertyDescriptor descriptor) throws NullPointerException, PropertyValidationException
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").
descriptor
- the key to the property.
null
is returned in cause of an optional property being not set.
NullPointerException
- if
descriptor
is
null
.
PropertyValidationException
- if the property is invalid according to its constraints.
String getPropertyValueAsString(String key) throws IllegalArgumentException, UnknownPropertyException, PropertyValidationException
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").
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.
PropertyValidationException
- if the property is invalid according to its constraints.
String getPropertyValueAsString(PropertyDescriptor descriptor, Object defaultValue) throws NullPointerException, PropertyValidationException
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").
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
.
PropertyValidationException
- if the property is invalid according to its constraints.
String getPropertyValueAsString(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, PropertyValidationException
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").
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.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
PropertyValidationException
- if the property is invalid according to its constraints.
void validate() throws ConfigurationValidationException
ConfigurationValidationException
- if the configuration contains properties that do not meet the required constraints.
void validate(Class<?>... groups) throws ConfigurationValidationException
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.
void validate(PropertyDescriptor descriptor, Class<?>... ifInOneOfTheseGroups) throws ConfigurationValidationException
descriptor
- the descriptor whose value is to be validated.
ifInOneOfTheseGroups
- the validation only takes place if this constraint is part of any of the specified groups or the argument is empty or
null
.
ConfigurationValidationException
- if property does not meet the required constraints.
void validate(PropertyDescriptor descriptor, String value, Class<?>... ifInOneOfTheseGroups) throws ConfigurationValidationException
descriptor
- the descriptor whose value is to be validated.
value
- the property value to be validated.
ifInOneOfTheseGroups
- the validation only takes place if this constraint is part of any of the specified groups or the argument is empty or
null
.
ConfigurationValidationException
- if property does not meet the required constraints.
void validate(boolean lenient, Class<?>... groups) throws ConfigurationValidationException
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.
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.
void addPropertyChangeListener(PropertyKey name, PropertyChangeListener listener) throws NullPointerException
name
- the name of the property to track changes.
listener
- the listener to add.
NullPointerException
- if
name
or
listener
is
null
.
void removePropertyChangeListener(PropertyKey name, PropertyChangeListener listener) throws NullPointerException
name
- the name of the property to stop tracking changes.
listener
- the listener to remove.
NullPointerException
- if
name
or
listener
is
null
.
void addPropertyChangeListener(PropertyChangeListener listener) throws NullPointerException
listener
- the listener to add.
NullPointerException
- if
listener
is
null
.
void removePropertyChangeListener(PropertyChangeListener listener) throws NullPointerException
listener
- the listener to remove.
NullPointerException
- if
listener
is
null
.
SerializableConfigurationProperties toSerializable()
ConfigurationPropertiesProxy
,
ConfigurationPropertiesManagementProxy
ConfigurationProperties toRepresentative()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |