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 PropertyDescriptors 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 PropertyDescriptors 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 PropertyDescriptors 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()
PropertySetgetProperties in interface PropertySetpublic boolean isPropertyDefined(String name)
PropertySetgetProperty(name) will
always return null.isPropertyDefined in interface PropertySetname - The property name or the property's alias name (both case sensitive).true if the property is defined.public Property getProperty(String name)
PropertySetgetProperty in interface PropertySetname - 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)
PropertySetaddProperty in interface PropertySetproperty - The property.public void addProperties(Property... properties)
PropertySetaddProperties in interface PropertySetproperties - The properties to be added.public void removeProperty(Property property)
PropertySetremoveProperty in interface PropertySetproperty - The property.public void removeProperties(Property... properties)
PropertySetremoveProperties in interface PropertySetproperties - The properties to be removed.public <T> T getValue(String name)
PropertySetgetValue in interface PropertySetname - The property name.null if a property with the given name does not exist.public void setValue(String name, Object value) throws IllegalArgumentException
PropertySetsetValue in interface PropertySetname - 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)
PropertySetgetDescriptor in interface PropertySetname - The property name (case sensitive).null if the property is unknown.public void setDefaultValues()
throws IllegalStateException
PropertySetsetDefaultValues in interface PropertySetIllegalStateException - If at least one of the default values is illegal.
The cause will always be a ValidationException.PropertyDescriptor.getDefaultValue()public void addPropertyChangeListener(PropertyChangeListener l)
PropertyChangeEmitteraddPropertyChangeListener in interface PropertyChangeEmitterl - The listener.public void addPropertyChangeListener(String name, PropertyChangeListener l)
PropertyChangeEmitteraddPropertyChangeListener in interface PropertyChangeEmittername - The property name.l - The listener.public void removePropertyChangeListener(PropertyChangeListener l)
PropertyChangeEmitterremovePropertyChangeListener in interface PropertyChangeEmitterl - The listener.public void removePropertyChangeListener(String name, PropertyChangeListener l)
PropertyChangeEmitterremovePropertyChangeListener in interface PropertyChangeEmittername - The property name.l - The listener.Copyright © 2014–2022 European Space Agency (ESA). All rights reserved.