Class BindingProvider


  • public class BindingProvider
    extends java.lang.Object
    Provides Bindings for constructors, methods and fields.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.reflect.Constructor<?> getAnnotatedConstructor​(java.lang.Class<?> cls)
      Returns an annotated Constructor suitable for injection.
      <T> java.lang.reflect.Constructor<T> getConstructor​(java.lang.Class<T> cls)
      Returns a Constructor suitable for injection.
      java.util.List<Binding> ofConstructor​(java.lang.reflect.Constructor<?> constructor)
      Returns all bindings for the given Constructor.
      java.util.List<Binding> ofConstructorAndMembers​(java.lang.reflect.Constructor<?> constructor, java.lang.Class<?> cls)
      Returns all bindings for the given Constructor and all member bindings for the given class.
      java.util.List<Binding> ofField​(java.lang.reflect.Field field, java.lang.reflect.Type ownerType)
      Returns all bindings for the given Field.
      java.util.List<Binding> ofMembers​(java.lang.Class<?> cls)
      Returns all member bindings for the given class.
      java.util.List<Binding> ofMethod​(java.lang.reflect.Method method, java.lang.reflect.Type ownerType)
      Returns all bindings for the given Method.
      • Methods inherited from class java.lang.Object

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

      • ofConstructorAndMembers

        public java.util.List<Binding> ofConstructorAndMembers​(java.lang.reflect.Constructor<?> constructor,
                                                               java.lang.Class<?> cls)
                                                        throws DefinitionException
        Returns all bindings for the given Constructor and all member bindings for the given class.
        Parameters:
        constructor - a Constructor to examine for bindings, cannot be null
        cls - a Class to examine for bindings, cannot be null
        Returns:
        a list of bindings, never null and never contains nulls, but can be empty
        Throws:
        DefinitionException - when a definition problem is encountered
      • ofConstructor

        public java.util.List<Binding> ofConstructor​(java.lang.reflect.Constructor<?> constructor)
                                              throws DefinitionException
        Returns all bindings for the given Constructor.
        Parameters:
        constructor - a Constructor to examine for bindings, cannot be null
        Returns:
        a list of bindings, never null and never contains nulls, but can be empty
        Throws:
        DefinitionException - when a definition problem is encountered
      • ofMembers

        public java.util.List<Binding> ofMembers​(java.lang.Class<?> cls)
                                          throws DefinitionException
        Returns all member bindings for the given class. These are inject annotated methods and fields, but not constructors.
        Parameters:
        cls - a Class to examine for bindings, cannot be null
        Returns:
        a list of bindings, never null and never contains null, but can be empty
        Throws:
        DefinitionException - when a definition problem is encountered
      • ofMethod

        public java.util.List<Binding> ofMethod​(java.lang.reflect.Method method,
                                                java.lang.reflect.Type ownerType)
                                         throws DefinitionException
        Returns all bindings for the given Method.
        Parameters:
        method - a Method to examine for bindings, cannot be null
        ownerType - a Type in which this method is declared, cannot be null
        Returns:
        a list of bindings, never null and never contains nulls, but can be empty
        Throws:
        DefinitionException - when a definition problem is encountered
      • ofField

        public java.util.List<Binding> ofField​(java.lang.reflect.Field field,
                                               java.lang.reflect.Type ownerType)
                                        throws DefinitionException
        Returns all bindings for the given Field.
        Parameters:
        field - a Field to examine for bindings, cannot be null
        ownerType - a Type in which this executable is declared, cannot be null
        Returns:
        an immutable list of bindings, never null and never contains nulls, but can be empty
        Throws:
        DefinitionException - when a definition problem is encountered
      • getAnnotatedConstructor

        public java.lang.reflect.Constructor<?> getAnnotatedConstructor​(java.lang.Class<?> cls)
                                                                 throws DefinitionException
        Returns an annotated Constructor suitable for injection.
        Parameters:
        cls - a Class, cannot be null
        Returns:
        a Constructor suitable for injection, never null
        Throws:
        DefinitionException - when a definition problem is encountered
      • getConstructor

        public <T> java.lang.reflect.Constructor<T> getConstructor​(java.lang.Class<T> cls)
                                                            throws DefinitionException
        Returns a Constructor suitable for injection. A public empty constructor is considered suitable if no other constructors are annotated.
        Type Parameters:
        T - the class type
        Parameters:
        cls - a Class, cannot be null
        Returns:
        a Constructor suitable for injection, never null
        Throws:
        DefinitionException - when a definition problem is encountered