public class BinderFactory extends Object
Binder
.
newBinder(XXX)
methods.
For example to obtain a mirrored binder (same source and target type) which
will be able to copy all accepting properties, use this code :
Binder<BeanA, BeanA> binder = BinderFactory.newBinder(BeanA.class);
Binder<BeanA, BeanA> binder = BinderFactory.newBinder(BeanA.class, "mycontext");This is usefull when you register your own binder model in the factory (see next section) to bind different things from the same type of objects...
registerBinderModel(XXX)
.
More documentation will come soon, yu can see the package info javadoc or
unit tests...Modifier and Type | Class and Description |
---|---|
static class |
BinderFactory.BindelModelEntryMap |
static class |
BinderFactory.BinderModelEntry
Definition of an binder model entry (source and target types + context name).
|
Modifier and Type | Field and Description |
---|---|
protected static BinderFactory.BindelModelEntryMap |
binderModels
Cache of registred binders indexed by their unique entry
|
Constructor and Description |
---|
BinderFactory() |
Modifier and Type | Method and Description |
---|---|
static void |
clear()
Clear the cache of registred binder models.
|
protected static BinderFactory.BindelModelEntryMap |
getBinderModels() |
static <S,T> Binder.BinderModel<S,T> |
getCachedBinderModel(Class<S> sourceType,
Class<T> targetType,
String contextName)
Obtain a cached binder model.
|
static <S,T> boolean |
isBinderModelExists(Class<S> sourceType,
Class<T> targetType,
String contextName)
Tells if there is a cached binder model for the given parameters.
|
static <S,T,B extends Binder<S,T>> |
newBinder(Binder.BinderModel<S,T> model,
Class<B> binderType)
Given a
model and a binderType , instanciate a new binder
and returns it. |
static <S> Binder<S,S> |
newBinder(Class<S> sourceType)
Gets the registred mirror binder (source type = target type) with no
context name specified.
|
static <S,T> Binder<S,T> |
newBinder(Class<S> sourceType,
Class<T> targetType)
Gets the registred binder given his types with no context name.
|
static <S,T> Binder<S,T> |
newBinder(Class<S> sourceType,
Class<T> targetType,
String contextName)
Gets the registred binder given his types with no context name.
|
static <S,T,B extends Binder<S,T>> |
newBinder(Class<S> sourceType,
Class<T> targetType,
String contextName,
Class<B> binderType)
Gets the registred binder given his types and his context's name.
|
static <S> Binder<S,S> |
newBinder(Class<S> sourceType,
String contextName)
Gets the registred mirror binder (source type = target type) with the
given context name.
|
protected static <S,T,B extends Binder<S,T>> |
newBinder0(Class<S> sourceType,
Class<T> targetType,
String contextName,
Class<B> binderType)
Instanciate a new binder given his types and his context's name.
|
static <S,T> Binder.BinderModel<S,T> |
registerBinderModel(Binder.BinderModel<S,T> model) |
static <S,T> Binder.BinderModel<S,T> |
registerBinderModel(Binder.BinderModel<S,T> model,
String contextName) |
static <S,T> Binder.BinderModel<S,T> |
registerBinderModel(Binder<S,T> binder) |
static <S,T> Binder.BinderModel<S,T> |
registerBinderModel(Binder<S,T> binder,
String contextName) |
static <S,T> Binder.BinderModel<S,T> |
registerBinderModel(BinderModelBuilder<S,T> binderModelBuilder) |
static <S,T> Binder.BinderModel<S,T> |
registerBinderModel(BinderModelBuilder<S,T> binderModelBuilder,
String contextName) |
protected static String |
toString(Binder.BinderModel<?,?> model,
String contextName) |
protected static String |
toString(Class<?> sourceType,
Class<?> targetType,
String contextName) |
protected static BinderFactory.BindelModelEntryMap binderModels
public static <S> Binder<S,S> newBinder(Class<S> sourceType)
S
- the type of source and targetsourceType
- the type of source and targetnull
if not found.public static <S> Binder<S,S> newBinder(Class<S> sourceType, String contextName)
S
- the type of source and targetsourceType
- the type of source and targetcontextName
- the context's name of the searched bindernull
if not found.public static <S,T> Binder<S,T> newBinder(Class<S> sourceType, Class<T> targetType)
S
- the type of sourceT
- the type of targetsourceType
- the type of sourcetargetType
- the type of targetnull
if not found.public static <S,T> Binder<S,T> newBinder(Class<S> sourceType, Class<T> targetType, String contextName)
S
- the type of sourceT
- the type of targetsourceType
- the type of sourcetargetType
- the type of targetcontextName
- the context's name of the searched bindernull
if not found.public static <S,T,B extends Binder<S,T>> B newBinder(Class<S> sourceType, Class<T> targetType, String contextName, Class<B> binderType)
S
- the type of sourceT
- the type of targetB
- the type of bindersourceType
- the type of sourcetargetType
- the type of targetcontextName
- the context's name of the searched binderbinderType
- type of binder requiredpublic static <S,T> Binder.BinderModel<S,T> registerBinderModel(BinderModelBuilder<S,T> binderModelBuilder) throws IllegalArgumentException
IllegalArgumentException
public static <S,T> Binder.BinderModel<S,T> registerBinderModel(Binder<S,T> binder) throws IllegalArgumentException
IllegalArgumentException
public static <S,T> Binder.BinderModel<S,T> registerBinderModel(Binder.BinderModel<S,T> model) throws IllegalArgumentException
IllegalArgumentException
public static <S,T> Binder.BinderModel<S,T> registerBinderModel(BinderModelBuilder<S,T> binderModelBuilder, String contextName) throws IllegalArgumentException
IllegalArgumentException
public static <S,T> Binder.BinderModel<S,T> registerBinderModel(Binder<S,T> binder, String contextName) throws IllegalArgumentException
IllegalArgumentException
public static <S,T> Binder.BinderModel<S,T> registerBinderModel(Binder.BinderModel<S,T> model, String contextName) throws IllegalArgumentException
IllegalArgumentException
public static <S,T,B extends Binder<S,T>> B newBinder(Binder.BinderModel<S,T> model, Class<B> binderType)
model
and a binderType
, instanciate a new binder
and returns it.
Note: This method will NOT register
the model in the factory. If you want to reuse your model, please use
one of the registerBinderModel(XXX)
method.S
- the source typeT
- the target typeB
- the type of the bindermodel
- the model used by the binderbinderType
- the type of the binderpublic static void clear()
public static <S,T> boolean isBinderModelExists(Class<S> sourceType, Class<T> targetType, String contextName)
S
- the type of sourceT
- the type of targetsourceType
- the type of sourcetargetType
- the type of targetcontextName
- the context's name of the searched bindertrue
if there is a cached binder model for the given
parameters, false
otherwise.public static <S,T> Binder.BinderModel<S,T> getCachedBinderModel(Class<S> sourceType, Class<T> targetType, String contextName)
S
- the type of sourceT
- the type of targetsourceType
- the type of sourcetargetType
- the type of targetcontextName
- the context's name of the searched bindernull
if not found.protected static BinderFactory.BindelModelEntryMap getBinderModels()
protected static String toString(Binder.BinderModel<?,?> model, String contextName)
protected static String toString(Class<?> sourceType, Class<?> targetType, String contextName)
protected static <S,T,B extends Binder<S,T>> Binder<S,T> newBinder0(Class<S> sourceType, Class<T> targetType, String contextName, Class<B> binderType)
BinderModelBuilder.newDefaultBuilder(Class, Class)
method).S
- the type of sourceT
- the type of targetB
- the type of bindersourceType
- the type of sourcetargetType
- the type of targetcontextName
- the context's name of the searched binderbinderType
- type of binder requiredCopyright © 2004–2020 CodeLutin. All rights reserved.