Class Binder

java.lang.Object
play.data.binding.Binder

public abstract class Binder extends Object
The binder try to convert String values to Java objects.
  • Field Details

    • MISSING

      public static final Object MISSING
  • Constructor Details

    • Binder

      public Binder()
  • Method Details

    • register

      public static <T> void register(@NonNull 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 register
      typeBinder - The custom binder
      See Also:
    • unregister

      public static <T> void unregister(@NonNull Class<T> clazz)
      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 parameters
      bean - the bean object
      annotations - 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 object
      annotations - annotation on the object
      value - value to bind
      clazz - class of the object
      type - type to bind
      Returns:
      The binding object
      Throws:
      ParseException