Package play.data.binding
Class Binder
- java.lang.Object
-
- play.data.binding.Binder
-
public abstract class Binder extends java.lang.Object
The binder try to convert String values to Java objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Binder.MethodAndParamInfo
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Object
MISSING
static java.lang.Object
NO_BINDING
-
Constructor Summary
Constructors Constructor Description Binder()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.Object
bind(java.lang.Object o, java.lang.String name, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.static java.lang.Object
bind(java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.static java.lang.Object
bind(RootParamNode parentParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
static java.lang.Object
bind(RootParamNode parentParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, Binder.MethodAndParamInfo methodAndParamInfo)
static void
bindBean(ParamNode paramNode, java.lang.Object bean, java.lang.annotation.Annotation[] annotations)
Does NOT invoke pluginsstatic void
bindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)
Invokes the plugins before using the internal bindBean.static java.lang.Object
directBind(java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz, java.lang.reflect.Type type)
Bind a objectstatic java.lang.Object
directBind(java.lang.String name, java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz)
Bind a objectstatic java.lang.Object
directBind(java.lang.String name, java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz, java.lang.reflect.Type type)
This method calls the user's defined binders prior to bind simple typestatic java.lang.Object
directBind(java.lang.String value, java.lang.Class<?> clazz)
Bind a objectprotected static java.lang.Object
internalBind(ParamNode paramNode, java.lang.Class<?> clazz, java.lang.reflect.Type type, BindingAnnotations bindingAnnotations)
static <T> void
register(java.lang.Class<T> clazz, TypeBinder<T> typeBinder)
Add custom binder for any given class E.g.static <T> void
unregister(java.lang.Class<T> clazz)
Remove custom binder that was add with method #register(java.lang.Class, play.data.binding.TypeBinder)
-
-
-
Method Detail
-
register
public static <T> void register(java.lang.Class<T> clazz, TypeBinder<T> typeBinder)
Add custom binder for any given class E.g. @{code Binder.register(BigDecimal.class, new MyBigDecimalBinder());} NB! Do not forget to UNREGISTER your custom binder when applications is reloaded (most probably in method onApplicationStop()). Otherwise you will have a memory leak.- Type Parameters:
T
- The Class type to register- Parameters:
clazz
- The class to registertypeBinder
- The custom binder- See Also:
unregister(java.lang.Class)
-
unregister
public static <T> void unregister(java.lang.Class<T> clazz)
Remove custom binder that was add with method #register(java.lang.Class, play.data.binding.TypeBinder)- Type Parameters:
T
- The Class type to register- Parameters:
clazz
- The class to remove the custom binder
-
bind
@Deprecated public static java.lang.Object bind(java.lang.Object o, java.lang.String name, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.Deprecated. Use bindBean() instead.- Parameters:
o
- Object to bindname
- Name of the objectparams
- List of the parameters- Returns:
- : The binding object
-
bind
@Deprecated public static java.lang.Object bind(java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, java.util.Map<java.lang.String,java.lang.String[]> params)
Deprecated.
-
bind
public static java.lang.Object bind(RootParamNode parentParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
-
bind
public static java.lang.Object bind(RootParamNode parentParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations, Binder.MethodAndParamInfo methodAndParamInfo)
-
internalBind
protected static java.lang.Object internalBind(ParamNode paramNode, java.lang.Class<?> clazz, java.lang.reflect.Type type, BindingAnnotations bindingAnnotations)
-
bindBean
public static void bindBean(RootParamNode rootParamNode, java.lang.String name, java.lang.Object bean)
Invokes the plugins before using the internal bindBean.- Parameters:
rootParamNode
- List of parametersname
- The object namebean
- the bean object
-
bindBean
public static void bindBean(ParamNode paramNode, java.lang.Object bean, java.lang.annotation.Annotation[] annotations)
Does NOT invoke plugins- Parameters:
paramNode
- List of parametersbean
- the bean objectannotations
- annotations associated with the object
-
directBind
public static java.lang.Object directBind(java.lang.String value, java.lang.Class<?> clazz) throws java.lang.Exception
Bind a object- Parameters:
value
- value to bindclazz
- class of the object- Returns:
- The binding object
- Throws:
java.lang.Exception
- if problem occurred during binding
-
directBind
public static java.lang.Object directBind(java.lang.String name, java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz) throws java.lang.Exception
Bind a object- Parameters:
name
- name of the objectannotations
- annotation on the objectvalue
- Value to bindclazz
- The class of the object- Returns:
- The binding object
- Throws:
java.lang.Exception
- if problem occurred during binding
-
directBind
public static java.lang.Object directBind(java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz, java.lang.reflect.Type type) throws java.lang.Exception
Bind a object- Parameters:
annotations
- annotation on the objectvalue
- value to bindclazz
- class of the objecttype
- type to bind- Returns:
- The binding object
- Throws:
java.lang.Exception
- if problem occurred during binding
-
directBind
public static java.lang.Object directBind(java.lang.String name, java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz, java.lang.reflect.Type type) throws java.lang.Exception
This method calls the user's defined binders prior to bind simple type- Parameters:
name
- name of the objectannotations
- annotation on the objectvalue
- value to bindclazz
- class of the objecttype
- type to bind- Returns:
- The binding object
- Throws:
java.lang.Exception
- if problem occurred during binding
-
-