public class PropertyContainer extends Object implements PropertySet
PropertySet
interface.
PropertyContainer
is basically an implementation of the Property List design pattern.Constructor and Description |
---|
PropertyContainer()
Constructs a new, empty property container.
|
Modifier and Type | Method and Description |
---|---|
void |
addProperties(Property... properties)
Adds the given properties to this set.
|
void |
addProperty(Property property)
Adds a property to this set.
|
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds a property change listener to this emitter.
|
void |
addPropertyChangeListener(String name,
PropertyChangeListener l)
Adds a dedicated property change listener to this emitter.
|
static PropertyContainer |
createForFields(Class<?> type,
PropertyDescriptorFactory descriptorFactory,
PropertyAccessorFactory accessorFactory,
boolean initValues)
Creates a property container for the given template type.
|
static PropertyContainer |
createMapBacked(Map<String,Object> map)
Creates a property container for a map backing the values.
|
static PropertyContainer |
createMapBacked(Map<String,Object> map,
Class<?> templateType)
Creates a property container for the given template type and map backing the values.
|
static PropertyContainer |
createMapBacked(Map<String,Object> map,
Class<?> templateType,
PropertyDescriptorFactory descriptorFactory)
Creates a property container for the given template type and map backing the values.
|
static PropertyContainer |
createMapBacked(Map<String,Object> map,
PropertySetDescriptor propertySetDescriptor)
Creates a property container for a map backing the values.
|
static PropertyContainer |
createObjectBacked(Object object)
Creates a property container for the given object.
|
static PropertyContainer |
createObjectBacked(Object object,
PropertyDescriptorFactory descriptorFactory)
Creates a property container for the given object.
|
static PropertyContainer |
createObjectBacked(Object object,
PropertySetDescriptor propertySetDescriptor) |
static PropertyContainer |
createValueBacked(Class<?> templateType)
Creates a property container for the given template type.
|
static PropertyContainer |
createValueBacked(Class<?> templateType,
PropertyDescriptorFactory descriptorFactory)
Creates a property container for the given template type.
|
PropertyDescriptor |
getDescriptor(String name)
Gets the descriptor for the named property.
|
Property[] |
getProperties()
Gets all properties currently contained in this set.
|
Property |
getProperty(String name)
Gets the named property.
|
<T> T |
getValue(String name)
Gets the value of the named property.
|
boolean |
isPropertyDefined(String name)
Tests if the named property is defined in this set.
|
void |
removeProperties(Property... properties)
Removes the given properties from this set.
|
void |
removeProperty(Property property)
Removes a property from this set.
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes a property change listener from this emitter.
|
void |
removePropertyChangeListener(String name,
PropertyChangeListener l)
Removes a dedicated property change listener from this emitter.
|
void |
setDefaultValues()
Sets all properties to their default values.
|
void |
setValue(String name,
Object value)
Sets the value of the named property.
|
public PropertyContainer()
public static PropertyContainer createObjectBacked(Object object)
object
- the backing objectpublic static PropertyContainer createObjectBacked(Object object, PropertyDescriptorFactory descriptorFactory)
object
- the backing objectdescriptorFactory
- a factory used to create PropertyDescriptor
s of the fields of the object's typepublic static PropertyContainer createObjectBacked(Object object, PropertySetDescriptor propertySetDescriptor)
public static PropertyContainer createMapBacked(Map<String,Object> map)
map
- the map which backs the valuespublic static PropertyContainer createMapBacked(Map<String,Object> map, PropertySetDescriptor propertySetDescriptor)
map
- the map which backs the valuespropertySetDescriptor
- A descriptor the property set to be created.public static PropertyContainer createMapBacked(Map<String,Object> map, Class<?> templateType)
map
- the map which backs the valuestemplateType
- the template typepublic static PropertyContainer createMapBacked(Map<String,Object> map, Class<?> templateType, PropertyDescriptorFactory descriptorFactory)
map
- the map which backs the valuestemplateType
- the template typedescriptorFactory
- a factory used to create PropertyDescriptor
s of the fields of the template typepublic static PropertyContainer createValueBacked(Class<?> templateType)
templateType
- the template typepublic static PropertyContainer createValueBacked(Class<?> templateType, PropertyDescriptorFactory descriptorFactory)
templateType
- the template class used to derive the descriptors fromdescriptorFactory
- a factory used to create PropertyDescriptor
s of the fields of the template typepublic static PropertyContainer createForFields(Class<?> type, PropertyDescriptorFactory descriptorFactory, PropertyAccessorFactory accessorFactory, boolean initValues)
descriptorFactory
and the accessorFactory
which
are called for each non-static and non-transient class field.type
- The type that provides the fields.descriptorFactory
- The property descriptor factory.accessorFactory
- The property accessor factory.initValues
- If true
, properties are initialised by their default values, if specified.public Property[] getProperties()
PropertySet
getProperties
in interface PropertySet
public boolean isPropertyDefined(String name)
PropertySet
getProperty(name)
will
always return null
.isPropertyDefined
in interface PropertySet
name
- The property name or the property's alias name (both case sensitive).true
if the property is defined.public Property getProperty(String name)
PropertySet
getProperty
in interface PropertySet
name
- The property name or the property's alias name (both case sensitive).null
if the property does not exist.PropertySet.isPropertyDefined(String)
,
PropertyDescriptor.getAlias()
public void addProperty(Property property)
PropertySet
addProperty
in interface PropertySet
property
- The property.public void addProperties(Property... properties)
PropertySet
addProperties
in interface PropertySet
properties
- The properties to be added.public void removeProperty(Property property)
PropertySet
removeProperty
in interface PropertySet
property
- The property.public void removeProperties(Property... properties)
PropertySet
removeProperties
in interface PropertySet
properties
- The properties to be removed.public <T> T getValue(String name)
PropertySet
getValue
in interface PropertySet
name
- The property name.null
if a property with the given name does not exist.public void setValue(String name, Object value) throws IllegalArgumentException
PropertySet
setValue
in interface PropertySet
name
- The property name.value
- The new property value.IllegalArgumentException
- If the value is illegal.
The cause will always be a ValidationException
.public PropertyDescriptor getDescriptor(String name)
PropertySet
getDescriptor
in interface PropertySet
name
- The property name (case sensitive).null
if the property is unknown.public void setDefaultValues() throws IllegalStateException
PropertySet
setDefaultValues
in interface PropertySet
IllegalStateException
- If at least one of the default values is illegal.
The cause will always be a ValidationException
.PropertyDescriptor.getDefaultValue()
public void addPropertyChangeListener(PropertyChangeListener l)
PropertyChangeEmitter
addPropertyChangeListener
in interface PropertyChangeEmitter
l
- The listener.public void addPropertyChangeListener(String name, PropertyChangeListener l)
PropertyChangeEmitter
addPropertyChangeListener
in interface PropertyChangeEmitter
name
- The property name.l
- The listener.public void removePropertyChangeListener(PropertyChangeListener l)
PropertyChangeEmitter
removePropertyChangeListener
in interface PropertyChangeEmitter
l
- The listener.public void removePropertyChangeListener(String name, PropertyChangeListener l)
PropertyChangeEmitter
removePropertyChangeListener
in interface PropertyChangeEmitter
name
- The property name.l
- The listener.Copyright © 2014–2016 European Space Agency (ESA). All rights reserved.