|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.util.beans.Binder<I,O>
I - the source bean typeO - the destination bean typepublic class Binder<I,O>
A binder permits to copy some properties from an object to another
one.
Binder.BinderModel which contains the mapping of properties
to transfert from the source object to the destination object.
Use the method copy(Object, Object, String...) to transfert properties.
Use the method obtainProperties(Object, String...) to obtain some
properties from a given object.
For more informations about how to obtain a binder, see the
BinderFactory or the package info javadoc or unit tests...
BinderFactory,
BinderModelBuilder,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
Binder.BinderModel<S,T>
Model of a Binder. |
static class |
Binder.CollectionStrategy
Types of loading of collections. |
| Field Summary | |
|---|---|
protected Binder.BinderModel<I,O> |
model
the model of the binder |
| Constructor Summary | |
|---|---|
Binder()
|
|
| Method Summary | |
|---|---|
protected Object |
bind(Binder binder,
Object read)
|
protected Object |
bindCollection(String sourceProperty,
Object read)
|
protected Object |
bindProperty(String sourceProperty,
Object read)
|
protected void |
copy(I source,
O target,
boolean excludeProperties,
String... propertyNames)
Copy properties from a source bean to a destination one according to the model of the binder. |
void |
copy(I source,
O target,
String... propertyNames)
Copy properties from a source bean to a destination one according to the model of the binder. |
void |
copyExcluding(I source,
O target,
String... propertyNames)
Copy properties from a source bean to a destination one according to the model of the binder excluding propertyNames. |
protected String[] |
getAllPropertiesExclude(String... propertyNameExcludes)
Obtains all properties from binder's model except those propertyNameExcludes. |
protected Object |
getCollectionValue(String sourceProperty,
Object readValue)
|
protected Binder.BinderModel<I,O> |
getModel()
Get the model of the binder. |
protected String[] |
getProperties(String... propertyNames)
Obtain the properties, if none is given in propertyNames
parameter, will use all property names defined in binder's model,
otherwise, check that all given property names are safe (registred in
binder's model). |
Class<I> |
getSourceType()
Obtains the type of the source bean. |
Class<O> |
getTargetType()
Obtains the type of the target bean. |
Map<String,Object> |
obtainProperties(I source,
String... propertyNames)
Obtain from the given object all properties registred in the binder model. |
protected void |
setModel(Binder.BinderModel<I,O> model)
Set the model of the binder. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Binder.BinderModel<I,O> model
| Constructor Detail |
|---|
public Binder()
| Method Detail |
|---|
public Class<I> getSourceType()
public Class<O> getTargetType()
public Map<String,Object> obtainProperties(I source,
String... propertyNames)
source - the bean to readpropertyNames - subset of properties to load
from is null.
public void copy(I source,
O target,
String... propertyNames)
propertyNames is defined, only
those properties will be copied.
Note: If from object is null, then null values
will be set to mapped properties into dst
source - the bean to readtarget - the bean to writepropertyNames - optional subset of properties to copy (if none is
specifed, will use all the properties defined in
binder)
NullPointerException - if target parameter is null
public void copyExcluding(I source,
O target,
String... propertyNames)
propertyNames.
Note: If from object is null, then null values
will be set to mapped properties into dst.
source - the bean to readtarget - the bean to writepropertyNames - optional subset of properties to copy (if none is
specifed, will use all the properties defined in
binder)
NullPointerException - if target parameter is null
protected void copy(I source,
O target,
boolean excludeProperties,
String... propertyNames)
throws RuntimeException
from object is null, then null values
will be set to mapped properties into dst.
source - the bean to readtarget - the bean to writeexcludeProperties - true to exclude following propertyNamespropertyNames - optional subset of properties to copy (if none is
specifed, will use all the properties defined in
binder)
NullPointerException - if target parameter is null
RuntimeException - if a property can not be copied to the target objectprotected Binder.BinderModel<I,O> getModel()
protected void setModel(Binder.BinderModel<I,O> model)
model - the model of the binderprotected String[] getProperties(String... propertyNames)
propertyNames
parameter, will use all property names defined in binder's model,
otherwise, check that all given property names are safe (registred in
binder's model).
propertyNames - optional subset of properties to get
protected String[] getAllPropertiesExclude(String... propertyNameExcludes)
propertyNameExcludes. Unknown properties will be ignored.
propertyNameExcludes - name of properties to exclude
protected Object getCollectionValue(String sourceProperty,
Object readValue)
protected Object bindProperty(String sourceProperty,
Object read)
throws IllegalAccessException,
InstantiationException
IllegalAccessException
InstantiationException
protected Object bindCollection(String sourceProperty,
Object read)
throws IllegalAccessException,
InstantiationException
IllegalAccessException
InstantiationException
protected Object bind(Binder binder,
Object read)
throws IllegalAccessException,
InstantiationException
IllegalAccessException
InstantiationException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||