|
||||||||||
| 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.
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
| Nested Class Summary | |
|---|---|
static class |
Binder.CollectionStrategy
Types of loading of collections. |
| Field Summary | |
|---|---|
protected BinderModel<I,O> |
model
the model of the binder |
| Constructor Summary | |
|---|---|
Binder()
|
|
| Method Summary | |
|---|---|
protected java.lang.Object |
bind(Binder binder,
java.lang.Object read)
|
protected java.lang.Object |
bindCollection(java.lang.String sourceProperty,
java.lang.Object read)
|
protected java.lang.Object |
bindProperty(java.lang.String sourceProperty,
java.lang.Object read)
|
protected void |
copy(I source,
O target,
boolean excludeProperties,
java.lang.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,
java.lang.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,
java.lang.String... propertyNames)
Copy properties from a source bean to a destination one according to the model of the binder excluding propertyNames. |
protected java.lang.String[] |
getAllPropertiesExclude(java.lang.String... propertyNameExcludes)
Obtains all properties from binder's model except those propertyNameExcludes. |
protected java.lang.Object |
getCollectionValue(java.lang.String sourceProperty,
java.lang.Object readValue)
|
protected BinderModel<I,O> |
getModel()
Get the model of the binder. |
protected java.lang.String[] |
getProperties(java.lang.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). |
java.lang.Class<I> |
getSourceType()
Obtains the type of the source bean. |
java.lang.Class<O> |
getTargetType()
Obtains the type of the target bean. |
java.util.Map<java.lang.String,java.lang.Object> |
obtainProperties(I source,
java.lang.String... propertyNames)
Obtain from the given object all properties registred in the binder model. |
protected void |
setModel(BinderModel<?,?> 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 BinderModel<I,O> model
| Constructor Detail |
|---|
public Binder()
| Method Detail |
|---|
public java.lang.Class<I> getSourceType()
public java.lang.Class<O> getTargetType()
public java.util.Map<java.lang.String,java.lang.Object> obtainProperties(I source,
java.lang.String... propertyNames)
source - the bean to readpropertyNames - subset of properties to load
from is null.
public void copy(I source,
O target,
java.lang.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)
java.lang.NullPointerException - if target parameter is null
public void copyExcluding(I source,
O target,
java.lang.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)
java.lang.NullPointerException - if target parameter is null
protected void copy(I source,
O target,
boolean excludeProperties,
java.lang.String... propertyNames)
throws java.lang.NullPointerException
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)
java.lang.NullPointerException - if target parameter is nullprotected BinderModel<I,O> getModel()
protected void setModel(BinderModel<?,?> model)
model - the model of the binderprotected java.lang.String[] getProperties(java.lang.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 java.lang.String[] getAllPropertiesExclude(java.lang.String... propertyNameExcludes)
propertyNameExcludes. Unknown properties will be ignored.
propertyNameExcludes - name of properties to exclude
protected java.lang.Object getCollectionValue(java.lang.String sourceProperty,
java.lang.Object readValue)
protected java.lang.Object bindProperty(java.lang.String sourceProperty,
java.lang.Object read)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.InstantiationException
protected java.lang.Object bindCollection(java.lang.String sourceProperty,
java.lang.Object read)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.InstantiationException
protected java.lang.Object bind(Binder binder,
java.lang.Object read)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.InstantiationException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||