|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.util.beans.BinderModelBuilder<S,T>
public class BinderModelBuilder<S,T>
Class to create a new Binder.BinderModel.
BinderFactory to obtain
a real Binder.
If you want to create more than one binder model, use each time a new
binder builder.
To obtain a new instance of a build please use one of the factories method :
newEmptyBuilder(Class)} to create a binder model with same
source and target typenewEmptyBuilder(Class, Class) to create a binder model with a
possible different source and target typenewDefaultBuilder(Class) to create a binder model with same
source and target type and then fill the model with all matching properties.newDefaultBuilder(Class, Class) to create a binder model
with a possible different source and target type and then fill the model
with all matching properties.addSimpleProperties(String...) to add in the binder model simple
properties (a simple property is a property present in both source and target type)addProperty(String, String) to add in the binder model a single
property (from source type) to be copied to another property (in target type)addProperties(String...) to add in the binder model properties
(says here you specify some couple of properties (sourcePropertyName,
targetPropertyName) to be added in the binder model)addBinder(String, Binder) to add in the binder model
another binder to be used to copy the given simple property (same name in
source and target type)addCollectionStrategy(Binder.CollectionStrategy, String...) to
specify the strategy to be used to bind some collection some source type to
target typebuilder.addSimpleProperties(...).addProperty(...).addBinder(...)Here is an example of how to use the
BinderModelBuilder :
BinderModelBuilderOnce the binder is registred into thebuilder = new BinderModelBuilder(Bean.class); builder.addSimpleProperties("name", "surname"); BinderFactory.registerBinderModel(builder); Binder binder = BinderFactory.getBinder(BeanA.class);
BinderFactory, you can get it
each time you need it :
Binderbinder = BinderFactory.getBinder(Bean.class);
Binder.BinderModel,
Binder| Field Summary | |
|---|---|
protected Binder.BinderModel<S,T> |
model
current model used to build the binder |
protected Map<String,PropertyDescriptor> |
sourceDescriptors
source properties descriptors |
protected Map<String,PropertyDescriptor> |
targetDescriptors
target properties descriptors |
| Constructor Summary | |
|---|---|
protected |
BinderModelBuilder(Class<S> sourceType,
Class<T> targetType)
Creates a binder for the given types. |
| Method Summary | ||
|---|---|---|
BinderModelBuilder<S,T> |
addBinder(String propertyName,
Binder<?,?> binder)
|
|
BinderModelBuilder<S,T> |
addCollectionStrategy(Binder.CollectionStrategy strategy,
String... propertyNames)
|
|
BinderModelBuilder<S,T> |
addProperties(String... sourceAndTargetProperties)
Add to the binder model some properties. |
|
BinderModelBuilder<S,T> |
addProperty(String sourceProperty,
String targetProperty)
Add to the binder model some simple properties (says source property name = target property name). |
|
protected void |
addProperty0(String sourceProperty,
String targetProperty)
|
|
BinderModelBuilder<S,T> |
addSimpleProperties(String... properties)
Add to the binder model some simple properties (says source property name = target property name). |
|
protected void |
clear()
|
|
protected Binder.BinderModel<S,T> |
getModel()
|
|
protected static void |
loadDescriptors(Class<?> type,
Map<String,PropertyDescriptor> descriptors)
|
|
static
|
newDefaultBuilder(Class<S> sourceType)
Creates a new mirrored model builder and fill the model with all matching and available property from the given type. |
|
static
|
newDefaultBuilder(Class<S> sourceType,
Class<T> targetType)
Creates a new model builder and fill the model with all matching and available properties from the source type to the target type. |
|
static
|
newDefaultBuilder(Class<S> sourceType,
Class<T> targetType,
boolean checkType)
Creates a new model builder and fill the model with all matching and available properties from the source type to the target type. |
|
static
|
newEmptyBuilder(Class<S> type)
Creates a new mirrored and empty model binder for the given type. |
|
static
|
newEmptyBuilder(Class<S> sourceType,
Class<T> targetType)
Creates a new empty model binder for the given types. |
|
Binder<S,T> |
toBinder()
Convinient method to create directly a Binder using the
underlying model the builder contains. |
|
|
toBinder(Class<B> binderType)
Convinient method to create directly a Binder using the
underlying model the builder contains. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Binder.BinderModel<S,T> model
protected Map<String,PropertyDescriptor> sourceDescriptors
protected Map<String,PropertyDescriptor> targetDescriptors
| Constructor Detail |
|---|
protected BinderModelBuilder(Class<S> sourceType,
Class<T> targetType)
sourceType - type of the source of the bindertargetType - type of the target of the binder| Method Detail |
|---|
public static <S> BinderModelBuilder<S,S> newEmptyBuilder(Class<S> type)
type.
type - the type of mirrored binder
public static <S,T> BinderModelBuilder<S,T> newEmptyBuilder(Class<S> sourceType,
Class<T> targetType)
sourceType - type of the source of the bindertargetType - type of the target of the binder
public static <S> BinderModelBuilder<S,S> newDefaultBuilder(Class<S> sourceType)
S - the mirrored type of the binder model to createsourceType - the mirrored type of the binder model to create
public static <S,T> BinderModelBuilder<S,T> newDefaultBuilder(Class<S> sourceType,
Class<T> targetType)
S - the source type of the binder model to createT - the target type of the binder model to createsourceType - the source type of the model to createtargetType - the target type of the model to create
public static <S,T> BinderModelBuilder<S,T> newDefaultBuilder(Class<S> sourceType,
Class<T> targetType,
boolean checkType)
S - the source type of the binder model to createT - the target type of the binder model to createsourceType - the source type of the model to createtargetType - the target type of the model to createcheckType - flag to check if properties has same types, otherwise skip them
public Binder<S,T> toBinder()
Binder using the
underlying model the builder contains.
Note: Using this method will not make reusable the model
via the BinderFactory.
BinderFactory.newBinder(Binder.BinderModel, Class)public <B extends Binder<S,T>> B toBinder(Class<B> binderType)
Binder using the
underlying model the builder contains.
Note: Using this method will not make reusable the model
via the BinderFactory.
B - type of binder to createbinderType - type of binder to create
BinderFactory.newBinder(Binder.BinderModel, Class)
public BinderModelBuilder<S,T> addSimpleProperties(String... properties)
throws IllegalStateException,
NullPointerException
properties - the name of mirrored property
IllegalStateException - if no model was previously created
NullPointerException - if a property is null
public BinderModelBuilder<S,T> addProperty(String sourceProperty,
String targetProperty)
throws IllegalStateException,
NullPointerException
sourceProperty - the name of the source property to bindtargetProperty - the name of the target property to bind
IllegalStateException - if no model was previously created
NullPointerException - if a parameter is null
public BinderModelBuilder<S,T> addProperties(String... sourceAndTargetProperties)
throws IllegalStateException,
IllegalArgumentException,
NullPointerException
sourceAndTargetProperties must be a array of couple
of sourceProperty, targetProperty.
Example :
builder.addProperties("name","name2","text","text");
Note: If no model is present, the method will fail.
sourceAndTargetProperties - the couple of (sourceProperty -
targetProperty) to bind
IllegalStateException - if no model was previously created
IllegalArgumentException - if there is not the same number of
source and target properties
NullPointerException - if a parameter is null
public BinderModelBuilder<S,T> addBinder(String propertyName,
Binder<?,?> binder)
public BinderModelBuilder<S,T> addCollectionStrategy(Binder.CollectionStrategy strategy,
String... propertyNames)
protected void addProperty0(String sourceProperty,
String targetProperty)
protected Binder.BinderModel<S,T> getModel()
protected void clear()
protected static void loadDescriptors(Class<?> type,
Map<String,PropertyDescriptor> descriptors)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||