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  
      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 plugins
      static 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 object
      static java.lang.Object directBind​(java.lang.String name, java.lang.annotation.Annotation[] annotations, java.lang.String value, java.lang.Class<?> clazz)
      Bind a object
      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)
      This method calls the user's defined binders prior to bind simple type
      static java.lang.Object directBind​(java.lang.String value, java.lang.Class<?> clazz)
      Bind a object
      protected 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)
      • 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
      • NO_BINDING

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

      • Binder

        public Binder()
    • 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 register
        typeBinder - 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 bind
        name - Name of the object
        params - 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 parameters
        name - The object name
        bean - 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 parameters
        bean - the bean object
        annotations - 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 bind
        clazz - 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 object
        annotations - annotation on the object
        value - Value to bind
        clazz - 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 object
        value - value to bind
        clazz - class of the object
        type - 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 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.lang.Exception - if problem occurred during binding