Package play.data.binding
Class Binder
java.lang.Object
play.data.binding.Binder
The binder try to convert String values to Java objects.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable Objectbind(Http.Request request, Scope.Session session, RootParamNode parentParamNode, String name, Class<?> clazz, Type type, Annotation[] annotations) static voidbindBean(Http.Request request, Scope.Session session, ParamNode paramNode, Object bean, Annotation[] annotations) Does NOT invoke pluginsstatic @Nullable ObjectdirectBind(String name, Http.Request request, Scope.Session session, Annotation[] annotations, String value, Class<?> clazz, Type type) This method calls the user's defined binders prior to bind simple typestatic <T> voidregister(@NonNull Class<T> clazz, @NonNull TypeBinder<T> typeBinder) Add custom binder for any given classstatic <T> voidunregister(@NonNull Class<T> clazz) Remove custom binder that was added with method #register(java.lang.Class, play.data.binding.TypeBinder)
-
Field Details
-
MISSING
-
-
Constructor Details
-
Binder
public Binder()
-
-
Method Details
-
register
Add custom binder for any given classE.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
Remove custom binder that was added 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
public static @Nullable Object bind(Http.Request request, Scope.Session session, RootParamNode parentParamNode, String name, Class<?> clazz, Type type, Annotation[] annotations) -
bindBean
public static void bindBean(Http.Request request, Scope.Session session, ParamNode paramNode, Object bean, Annotation[] annotations) Does NOT invoke plugins- Parameters:
paramNode- List of parametersbean- the bean objectannotations- annotations associated with the object
-
directBind
public static @Nullable Object directBind(String name, Http.Request request, Scope.Session session, Annotation[] annotations, String value, Class<?> clazz, Type type) throws ParseException 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:
ParseException
-