T
- Bean class to which this property set referspublic interface BeanPropertySet<T> extends PropertySet<PathProperty<?>>, BeanPropertyInspector, DataMappable
PropertySet
collecting and providing Java Bean property set and configuration as PathProperty
property type elements.BeanIntrospector
Modifier and Type | Interface and Description |
---|---|
static interface |
BeanPropertySet.Builder<T,B extends BeanPropertySet<T>>
BeanPropertySet builder. |
CONTEXT_KEY, PROPERTY_CONFIGURATION_ATTRIBUTE
DEFAULT_CONFIG_PROPERTY_PREFIX, PATH
Modifier and Type | Method and Description |
---|---|
static <T> BeanPropertySet<T> |
create(Class<? extends T> beanClass)
Create a bean property set using default
BeanIntrospector . |
static <T> BeanPropertySet<T> |
create(Class<? extends T> beanClass,
Path<?> parentPath)
Deprecated.
The root bean property path will always be a
Path.FinalPath typed on bean class and with the bean
class name as path name. Use create(Class) instead. |
Class<? extends T> |
getBeanClass()
Get the bean class to which this property set refers.
|
default Optional<String> |
getDataPath()
Get the data model path name to which this bean property set is mapped.
|
<V> V |
read(Path<V> path,
T instance)
Read the value of the property bound to given
path from given bean instance, using full path name to
match the bean property to read. |
default PropertyBox |
read(PropertyBox propertyBox,
T instance)
Read the property values from given bean instance into the given
PropertyBox , using given
propertyBox property set. |
PropertyBox |
read(PropertyBox propertyBox,
T instance,
boolean ignoreMissing)
Read the property values from given bean instance into the given
PropertyBox , using given
propertyBox property set. |
<V> V |
read(String propertyName,
T instance)
Read the value of the property with given
propertyName from given bean instance. |
default PropertyBox |
read(T instance)
Read the property values from given bean instance into a
PropertyBox with this property set. |
<P> void |
write(Path<P> path,
P value,
T instance)
Write the
value bound to given path to given bean instance, using full path name to
match the bean property to write. |
default T |
write(PropertyBox propertyBox,
T instance)
Write the property values contained into given
PropertyBox into given bean instance. |
T |
write(PropertyBox propertyBox,
T instance,
boolean ignoreMissing)
Write the property values contained into given
PropertyBox into given bean instance. |
void |
write(String propertyName,
Object value,
T instance)
Write the
value of the property with given propertyName to given bean instance. |
asList, builder, builder, builderOf, contains, execute, getConfiguration, getFirstIdentifier, getIdentifiers, identifiers, join, of, of, of, size, stream
forEach, iterator, spliterator
hasConfiguration
contains, getProperty, getProperty, getPropertyBoolean, getPropertyNumeric, getPropertyNumeric, getPropertyString, getPropertyTemporal, getPropertyTemporal, property, property, propertyBoolean, propertyNumeric, propertyNumeric, propertyString, propertyTemporal, propertyTemporal, requireProperty, requireProperty, stream
isDataMappable
Class<? extends T> getBeanClass()
<V> V read(String propertyName, T instance)
propertyName
from given bean instance.V
- Property and result typepropertyName
- Name of the property to read (not null)instance
- Bean instance from which to read the property value (not null)Property.PropertyNotFoundException
- If a property with given name is not found in this property setProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If actual property type and expected type mismatch<V> V read(Path<V> path, T instance)
path
from given bean instance, using full path name to
match the bean property to read.V
- Path and value typepath
- Property path to read (not null)instance
- Bean instance from which to read the property value (not null)Property.PropertyNotFoundException
- If a property wich corresponds to given path name is not found in this property
setProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If actual property type and expected type mismatchvoid write(String propertyName, Object value, T instance)
value
of the property with given propertyName
to given bean instance.propertyName
- Name of the property to write (not null)value
- Value to write (may be null)instance
- Bean instance to which to write the property valueProperty.PropertyNotFoundException
- If a property with given name is not found in this property setProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If actual property type and expected type mismatch<P> void write(Path<P> path, P value, T instance)
value
bound to given path
to given bean instance, using full path name to
match the bean property to write.P
- Path and value typepath
- Property path to write (not null)value
- Value to write (may be null)instance
- Bean instance to which to write the property valueProperty.PropertyNotFoundException
- If a property wich corresponds to given path name is not found in this property
setProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If actual property type and expected type mismatchPropertyBox read(PropertyBox propertyBox, T instance, boolean ignoreMissing)
PropertyBox
, using given
propertyBox
property set.
The matching between the PropertyBox properties and the bean properties is performed by property name, so only
the PropertyBox properties which implements Path
will be taken into account, using Path.getName()
as property name.
Any PropertyValueConverter
will be applied to read values from bean data model.
propertyBox
- PropertyBox into which to write the property values (not null)instance
- Bean instance from which read the property values (not null)ignoreMissing
- true
to ignore properties of the PropertyBox property set which are not present
as bean property. If false
, when a property of the PropertyBox property set does not match
with any of the bean properties, a Property.PropertyNotFoundException
is thrown.Property.PropertyNotFoundException
- If ignoreMissing
is false
and a property of the
PropertyBox property set does not match with any of the bean propertiesProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If the bean property type and the PropertyBox property type mismatch for a propertyValidator.ValidationException
- If not PropertyBox.isInvalidAllowed()
for given property box and one of the
property values validation faileddefault PropertyBox read(PropertyBox propertyBox, T instance)
PropertyBox
, using given
propertyBox
property set.
The matching between the PropertyBox properties and the bean properties is performed by property name, so only
the PropertyBox properties which implements Path
will be taken into account, using Path.getName()
as property name.
Any PropertyValueConverter
will be applied to read values from bean data model.
propertyBox
- PropertyBox into which to write the property values (not null)instance
- Bean instance from which read the property values (not null)Property.PropertyNotFoundException
- If a property of the PropertyBox property set does not match with any of the
bean propertiesProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If the bean property type and the PropertyBox property type mismatch for a propertyValidator.ValidationException
- If not PropertyBox.isInvalidAllowed()
for given property box and one of the
property values validation faileddefault PropertyBox read(T instance)
PropertyBox
with this property set.
By default, the created PropertyBox allows invalid values, so no property value validation is performed.
Any PropertyValueConverter
will be applied to read values from bean data model.
instance
- Bean instance from which read the property values (not null)Property.PropertyAccessException
- Error accessing bean propertiesT write(PropertyBox propertyBox, T instance, boolean ignoreMissing)
PropertyBox
into given bean instance.
The matching between the PropertyBox properties and the bean properties is performed by property name, so only
the PropertyBox properties which implements PathProperty
will be taken into account, using
Path.getName()
as property name.
Any PropertyValueConverter
will be applied to write values to bean data model.
propertyBox
- PropertyBox from which read the property values (not null)instance
- Bean instance to which to write the property values (not null)ignoreMissing
- true
to ignore properties of the PropertyBox property set which are not present
as bean property. If false
, when a property of the PropertyBox property set does not match
with any of the bean properties, a Property.PropertyNotFoundException
is thrown.Property.PropertyNotFoundException
- If ignoreMissing
is false
and a property of the
PropertyBox property set does not match with any of the bean propertiesProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If the bean property type and the PropertyBox property type mismatch for a propertydefault T write(PropertyBox propertyBox, T instance)
PropertyBox
into given bean instance.
The matching between the PropertyBox properties and the bean properties is performed by property name, so only
the PropertyBox properties which implements PathProperty
will be taken into account, using
Path.getName()
as property name.
Any PropertyValueConverter
will be applied to write values to bean data model.
propertyBox
- PropertyBox from which read the property values (not null)instance
- Bean instance to which to write the property values (not null)Property.PropertyNotFoundException
- If a property of the PropertyBox property set does not match with any of the
bean propertiesProperty.PropertyAccessException
- Error accessing bean propertiesTypeMismatchException
- If the bean property type and the PropertyBox property type mismatch for a propertydefault Optional<String> getDataPath()
If the DataMappable.PATH
configuration property is present, the property value is returned. Otherwise,
the simple bean class name is returned.
The DataPath
annotation can be used on bean class to declare the data path at bean introspection time.
getDataPath
in interface DataMappable
static <T> BeanPropertySet<T> create(Class<? extends T> beanClass)
BeanIntrospector
.T
- Bean typebeanClass
- Bean class for which to create the property set (not null)PropertySet
of the properties detected from given bean class@Deprecated static <T> BeanPropertySet<T> create(Class<? extends T> beanClass, Path<?> parentPath)
Path.FinalPath
typed on bean class and with the bean
class name as path name. Use create(Class)
instead.BeanIntrospector
. If a parentPath
is specified, it
will be setted as bean root properties parent path.T
- Bean typebeanClass
- Bean class for which to create the property set (not null)parentPath
- Optional parent path to set as bean root properties parent pathPropertySet
of the properties detected from given bean classCopyright © 2019 The Holon Platform. All rights reserved.