Package play.data.binding
Class Binder
- java.lang.Object
-
- play.data.binding.Binder
-
public abstract class Binder extends java.lang.ObjectThe binder try to convert String values to Java objects.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ObjectMISSING
-
Constructor Summary
Constructors Constructor Description Binder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Objectbind(Http.Request request, Scope.Session session, RootParamNode parentParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)static voidbindBean(Http.Request request, Scope.Session session, ParamNode paramNode, java.lang.Object bean, java.lang.annotation.Annotation[] annotations)Does NOT invoke pluginsstatic java.lang.ObjectdirectBind(java.lang.String name, Http.Request request, Scope.Session session, 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 <T> voidregister(java.lang.Class<T> clazz, TypeBinder<T> typeBinder)Add custom binder for any given class E.g.static <T> voidunregister(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(@Nonnull java.lang.Class<T> clazz, @Nonnull 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(Class)
-
unregister
public static <T> void unregister(@Nonnull 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
@Nullable public static java.lang.Object bind(Http.Request request, Scope.Session session, RootParamNode parentParamNode, java.lang.String name, java.lang.Class<?> clazz, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
-
bindBean
public static void bindBean(Http.Request request, Scope.Session session, 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
@Nullable public static java.lang.Object directBind(java.lang.String name, Http.Request request, Scope.Session session, java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz, java.lang.reflect.Type type) throws java.text.ParseExceptionThis 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.text.ParseException
-
-