POJO - is the templated type of the POJO.public abstract class AbstractPojoDescriptor<POJO> extends Object implements PojoDescriptor<POJO>
PojoDescriptor interface.| Modifier and Type | Field and Description |
|---|---|
private PojoDescriptorBuilder |
pojoDescriptorBuilder |
private GenericType<POJO> |
pojoType |
| Constructor and Description |
|---|
AbstractPojoDescriptor(GenericType<POJO> pojoType,
PojoDescriptorBuilder pojoDescriptorBuilder)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
addPropertyItem(POJO pojo,
String propertyName,
Object item)
|
<ACCESSOR extends PojoPropertyAccessor> |
getAccessor(String property,
PojoPropertyAccessorMode<ACCESSOR> mode)
This method gets the
accessor for the property with the given propertyName and
for the given access mode. |
abstract PojoPropertyDescriptorImpl |
getOrCreatePropertyDescriptor(String propertyName)
This method gets the property-descriptor for the given
propertyName. |
Class<POJO> |
getPojoClass()
This method gets the type reflecting the
Pojo this object is related to. |
protected PojoDescriptorBuilder |
getPojoDescriptorBuilder() |
GenericType<POJO> |
getPojoType()
This method gets the
GenericType reflecting the Pojo this object is
related to. |
Object |
getProperty(POJO pojo,
String property)
|
private Object |
getProperty(POJO pojo,
String propertyPath,
boolean required) |
<V> V |
getProperty(POJO pojo,
TypedProperty<V> property)
This method gets the value of the specified property in a type-safe way.
|
PojoPropertyDescriptor |
getPropertyDescriptor(TypedProperty<?> property)
This method gets the
descriptor for the given property. |
abstract Collection<? extends AbstractPojoPropertyDescriptor> |
getPropertyDescriptors()
This method gets the
descriptors of all properties of the according
pojo. |
Object |
getPropertyItem(POJO pojo,
String propertyName,
int index)
This method gets the item with the given
index from the list-like property with the given propertyName of the given pojo using the
indexed
getter accessor. |
int |
getPropertySize(POJO pojo,
String propertyName)
|
Boolean |
removePropertyItem(POJO pojo,
String propertyName,
Object item)
This method removes the given
item from an array or Collection using the
remove
property with the given propertyName from the given pojo
accessor. |
Object |
setProperty(POJO pojo,
String propertyName,
Object value)
|
<V> void |
setProperty(POJO pojo,
TypedProperty<V> property,
V value)
This method sets the value of the specified property in a type-safe way.
|
Object |
setPropertyItem(POJO pojo,
String propertyName,
int index,
Object item)
This method sets the given
item at the given index in the list-like
property with the given propertyName of the given pojo using
the indexed
setter accessor. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAccessor, getPropertyDescriptor, newInstanceprivate final PojoDescriptorBuilder pojoDescriptorBuilder
private final GenericType<POJO> pojoType
public AbstractPojoDescriptor(GenericType<POJO> pojoType, PojoDescriptorBuilder pojoDescriptorBuilder)
pojoType - is the pojo-type.pojoDescriptorBuilder - is the PojoDescriptorBuilder.public Class<POJO> getPojoClass()
PojoAttributeTypePojo this object is related to.getPojoClass in interface PojoAttributeType<POJO>Pojo.public GenericType<POJO> getPojoType()
PojoAttributeTypeGenericType reflecting the Pojo this object is
related to.getPojoType in interface PojoAttributeType<POJO>Pojo.protected PojoDescriptorBuilder getPojoDescriptorBuilder()
PojoDescriptorBuilder instance.public abstract Collection<? extends AbstractPojoPropertyDescriptor> getPropertyDescriptors()
PojoDescriptordescriptors of all properties of the according
pojo.getPropertyDescriptors in interface PojoDescriptor<POJO>property descriptorspublic abstract PojoPropertyDescriptorImpl getOrCreatePropertyDescriptor(String propertyName)
propertyName.propertyName - is the name of the requested property-descriptor.null if NO property exists with the given propertyName
.public <ACCESSOR extends PojoPropertyAccessor> ACCESSOR getAccessor(String property, PojoPropertyAccessorMode<ACCESSOR> mode)
PojoDescriptoraccessor for the property with the given propertyName and
for the given access mode.getAccessor in interface PojoDescriptor<POJO>ACCESSOR - is the type of the requested accessor.property - is the name of the property. If the given mode is
GET it is treated as
for PojoDescriptor.getProperty(Object, String). If the given mode is
SET it is treated as
for PojoDescriptor.setProperty(Object, String, Object).mode - is the mode of the requested accessor. Use
PojoPropertyAccessorModes for available modes.null if NOT found (there is no property named propertyName, the
property has no accessor for the given mode, etc.).public Object getProperty(POJO pojo, String property)
PojoDescriptorproperty identified by the given property from
the given pojo. The result depends on the form of the given property as shown by the following
table:property |
accessor | example | equivalent |
|---|---|---|---|
[a-zA-Z][a-zA-Z0-9]* |
PojoPropertyAccessorNonArgMode.GET |
fooBar |
|
[a-zA-Z][a-zA-Z0-9]* "[" [0-9]+ "]" |
PojoPropertyAccessorIndexedNonArgMode.GET_INDEXED
|
fooBar[42] |
|
[a-zA-Z][a-zA-Z0-9]* "['" [a-zA-Z0-9]+ "']" |
PojoPropertyAccessorOneArgMode.GET_MAPPED
|
fooBar['key'] |
|
getProperty in interface PojoDescriptor<POJO>pojo - is the POJO instance where to access the property.property - identifies the property to get as described above.type of the according
getter. Depending
on the POJO, the value may be null.public <V> V getProperty(POJO pojo, TypedProperty<V> property) throws PojoPropertyNotFoundException, ReflectionException
PojoDescriptorgetProperty in interface PojoDescriptor<POJO>V - is the generic type of the requested property value.pojo - is the POJO instance where to access the property.property - is the TypedProperty identifying the property to get.PojoPropertyNotFoundException - if the property with the given propertyName was NOT
found or has no such accessor (getter).ReflectionException - if the underlying accessor caused an
error during reflection.PojoDescriptor.getProperty(Object, String)public Object setProperty(POJO pojo, String propertyName, Object value)
PojoDescriptorvalue for the property with the given
property of the given pojo. The effect depends on the form of the given property as shown
by the following table:property |
accessor | example | equivalent |
|---|---|---|---|
[a-zA-Z][a-zA-Z0-9]* |
PojoPropertyAccessorOneArgMode.SET |
fooBar |
|
[a-zA-Z][a-zA-Z0-9]* "[" [0-9]+ "]" |
PojoPropertyAccessorIndexedOneArgMode.SET_INDEXED
|
fooBar[42] |
|
[a-zA-Z][a-zA-Z0-9]* "['" [a-zA-Z0-9]+ "']" |
PojoPropertyAccessorTwoArgMode.SET_MAPPED
|
fooBar['key'] |
|
setProperty in interface PojoDescriptor<POJO>pojo - is the POJO instance where to access the property.propertyName - identifies the property to set as explained above.value - is the property value to set. Depending on the POJO the value may be null.null if the return type is void what should be the
regular case.public <V> void setProperty(POJO pojo, TypedProperty<V> property, V value) throws PojoPropertyNotFoundException, ReflectionException
PojoDescriptorsetProperty in interface PojoDescriptor<POJO>V - is the generic type of the property value to set.pojo - is the Pojo owning the property.property - is the TypedProperty identifying the property to set.value - is the new property value to set.PojoPropertyNotFoundException - if the property with the given propertyName was NOT
found or has no such accessor (setter).ReflectionException - if the underlying accessor caused an
error during reflection.PojoDescriptor.setProperty(Object, String, Object)private Object getProperty(POJO pojo, String propertyPath, boolean required)
pojo - is the POJO instance where to access the property.propertyPath - is the POJO property path.required - - true if the result is required, false if any intermediate or the end result may
be null resulting in null being returned.public int getPropertySize(POJO pojo, String propertyName)
PojoDescriptorgetPropertySize in interface PojoDescriptor<POJO>pojo - is the POJO instance where to access the property.propertyName - is the name of the property.public Object addPropertyItem(POJO pojo, String propertyName, Object item)
PojoDescriptoritem to the list-like property with the
given propertyName from the given pojo using the
add
accessor.addPropertyItem in interface PojoDescriptor<POJO>pojo - is the POJO instance where to access the property.propertyName - is the name of the property.item - is the item to add to the property.null if the return type is void what should be the
regular case.public Boolean removePropertyItem(POJO pojo, String propertyName, Object item)
PojoDescriptoritem from an array or Collection using the
remove
property with the given propertyName from the given pojo
accessor.removePropertyItem in interface PojoDescriptor<POJO>pojo - is the POJO instance where to access the property.propertyName - is the name of the property.item - is the item to remove from the property.Boolean.TRUE if the item has been removed successfully and Boolean.FALSE if the item was
NOT present in the array or Collection, or null if the accessor is pointing to a remove
method that returns no boolean.public Object getPropertyItem(POJO pojo, String propertyName, int index)
PojoDescriptorindex from the list-like property with the given propertyName of the given pojo using the
indexed
getter accessor.getPropertyItem in interface PojoDescriptor<POJO>pojo - is the POJO instance where to add the given property item.propertyName - is the name of the property.index - is the position of the requested item (see List.get(int)).null if the return type is void what should be the
regular case.public Object setPropertyItem(POJO pojo, String propertyName, int index, Object item)
PojoDescriptoritem at the given index in the list-like
property with the given propertyName of the given pojo using
the indexed
setter accessor.setPropertyItem in interface PojoDescriptor<POJO>pojo - is the POJO instance where to access the property.propertyName - is the name of the property.index - is the position of the item to set (see List.set(int, Object)).item - is the item to set at the given index.null if the return type is void what should be the
regular case.public PojoPropertyDescriptor getPropertyDescriptor(TypedProperty<?> property)
PojoDescriptordescriptor for the given property.getPropertyDescriptor in interface PojoDescriptor<POJO>property - is the TypedProperty.property.Copyright © 2001–2016 mmm-Team. All rights reserved.