Class Binder


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

      Fields 
      Modifier and Type Field Description
      static java.lang.Object MISSING  
    • Constructor Summary

      Constructors 
      Constructor Description
      Binder()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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)  
      static void bindBean​(Http.Request request, Scope.Session session, ParamNode paramNode, java.lang.Object bean, java.lang.annotation.Annotation[] annotations)
      Does NOT invoke plugins
      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)
      This method calls the user's defined binders prior to bind simple type
      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)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MISSING

        public static final java.lang.Object MISSING
    • Constructor Detail

      • Binder

        public Binder()
    • 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 register
        typeBinder - 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 parameters
        bean - the bean object
        annotations - 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.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:
        java.text.ParseException