Class BeanBag.SupplierBuilder<T>

  • Type Parameters:
    T - the bean type
    Enclosing class:
    BeanBag

    public static final class BeanBag.SupplierBuilder<T>
    extends Object
    A builder for a bean supplier which constructs a bean using reflection.
    • Method Detail

      • setConstructor

        public BeanBag.SupplierBuilder<T> setConstructor​(Constructor<T> constructor)
        Set the constructor to use to instantiate the bean.
        Parameters:
        constructor - the constructor (must not be null)
        Returns:
        this builder (not null)
      • injectField

        public BeanBag.SupplierBuilder<T> injectField​(Field field,
                                                      BeanSupplier<?> supplier)
        Add a general field injection.
        Parameters:
        field - the field to inject into (must not be null)
        supplier - the supplier of the field's value (must not be null)
        Returns:
        this builder (not null)
      • injectField

        public BeanBag.SupplierBuilder<T> injectField​(Field field,
                                                      Class<?> injectType,
                                                      String beanName,
                                                      boolean optional,
                                                      DependencyFilter filter)
        Add a bean dependency field injection.
        Parameters:
        field - the field to inject into (must not be null)
        injectType - the bean type to inject (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        Returns:
        this builder (not null)
      • injectField

        public BeanBag.SupplierBuilder<T> injectField​(Field field)
        Add a bean dependency field injection. The type of the bean is derived from the field's type.
        Parameters:
        field - the field to inject into (must not be null)
        Returns:
        this builder (not null)
      • injectField

        public BeanBag.SupplierBuilder<T> injectField​(Field field,
                                                      String beanName)
        Add a bean dependency field injection. The type of the bean is derived from the field's type.
        Parameters:
        field - the field to inject into (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        Returns:
        this builder (not null)
      • injectField

        public BeanBag.SupplierBuilder<T> injectField​(Field field,
                                                      boolean optional)
        Add a bean dependency field injection. The type of the bean is derived from the field's type.
        Parameters:
        field - the field to inject into (must not be null)
        optional - true to allow null to be injected, or false otherwise
        Returns:
        this builder (not null)
      • injectField

        public BeanBag.SupplierBuilder<T> injectField​(Field field,
                                                      String beanName,
                                                      boolean optional)
        Add a bean dependency field injection. The type of the bean is derived from the field's type.
        Parameters:
        field - the field to inject into (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        Returns:
        this builder (not null)
      • injectField

        public BeanBag.SupplierBuilder<T> injectField​(Field field,
                                                      String beanName,
                                                      boolean optional,
                                                      DependencyFilter filter)
        Add a bean dependency field injection. The type of the bean is derived from the field's type.
        Parameters:
        field - the field to inject into (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        Returns:
        this builder (not null)
      • injectMethod

        public BeanBag.SupplierBuilder<T> injectMethod​(Method method,
                                                       BeanSupplier<?> supplier)
        Add a general method injection.
        Parameters:
        method - the method to inject into (must not be null)
        supplier - the supplier of the method's value (must not be null)
        Returns:
        this builder (not null)
      • injectMethod

        public BeanBag.SupplierBuilder<T> injectMethod​(Method method,
                                                       Class<?> injectType,
                                                       String beanName,
                                                       boolean optional,
                                                       DependencyFilter filter)
        Add a bean dependency method injection.
        Parameters:
        method - the method to inject into (must not be null)
        injectType - the bean type to inject (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        Returns:
        this builder (not null)
      • injectMethod

        public BeanBag.SupplierBuilder<T> injectMethod​(Method method)
        Add a bean dependency method injection. The type of the bean is derived from the method's sole argument type.
        Parameters:
        method - the method to inject into (must not be null)
        Returns:
        this builder (not null)
      • injectMethod

        public BeanBag.SupplierBuilder<T> injectMethod​(Method method,
                                                       String beanName)
        Add a bean dependency method injection. The type of the bean is derived from the method's sole argument type.
        Parameters:
        method - the method to inject into (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        Returns:
        this builder (not null)
      • injectMethod

        public BeanBag.SupplierBuilder<T> injectMethod​(Method method,
                                                       boolean optional)
        Add a bean dependency method injection. The type of the bean is derived from the method's sole argument type.
        Parameters:
        method - the method to inject into (must not be null)
        optional - true to allow null to be injected, or false otherwise
        Returns:
        this builder (not null)
      • injectMethod

        public BeanBag.SupplierBuilder<T> injectMethod​(Method method,
                                                       String beanName,
                                                       boolean optional)
        Add a bean dependency method injection. The type of the bean is derived from the method's sole argument type.
        Parameters:
        method - the method to inject into (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        Returns:
        this builder (not null)
      • injectMethod

        public BeanBag.SupplierBuilder<T> injectMethod​(Method method,
                                                       String beanName,
                                                       boolean optional,
                                                       DependencyFilter filter)
        Add a bean dependency method injection. The type of the bean is derived from the method's sole argument type.
        Parameters:
        method - the method to inject into (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        Returns:
        this builder (not null)
      • addConstructorArgument

        public BeanBag.SupplierBuilder<T> addConstructorArgument​(BeanSupplier<?> supplier)
        Add a general constructor argument injection.
        Parameters:
        supplier - the supplier of the argument's value (must not be null)
        Returns:
        this builder (not null)
      • addConstructorArgument

        public BeanBag.SupplierBuilder<T> addConstructorArgument​(Class<?> injectType)
        Add a bean dependency constructor argument injection.
        Parameters:
        injectType - the bean type to inject (must not be null)
        Returns:
        this builder (not null)
      • addConstructorArgument

        public BeanBag.SupplierBuilder<T> addConstructorArgument​(Class<?> injectType,
                                                                 boolean optional)
        Add a bean dependency constructor argument injection.
        Parameters:
        injectType - the bean type to inject (must not be null)
        optional - true to allow null to be injected, or false otherwise
        Returns:
        this builder (not null)
      • addConstructorArgument

        public BeanBag.SupplierBuilder<T> addConstructorArgument​(Class<?> injectType,
                                                                 String beanName)
        Add a bean dependency constructor argument injection.
        Parameters:
        injectType - the bean type to inject (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        Returns:
        this builder (not null)
      • addConstructorArgument

        public BeanBag.SupplierBuilder<T> addConstructorArgument​(Class<?> injectType,
                                                                 String beanName,
                                                                 boolean optional)
        Add a bean dependency constructor argument injection.
        Parameters:
        injectType - the bean type to inject (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        Returns:
        this builder (not null)
      • addConstructorArgument

        public BeanBag.SupplierBuilder<T> addConstructorArgument​(Class<?> injectType,
                                                                 String beanName,
                                                                 boolean optional,
                                                                 DependencyFilter filter)
        Add a bean dependency constructor argument injection.
        Parameters:
        injectType - the bean type to inject (must not be null)
        beanName - the bean name to inject or "" for any (must not be null)
        optional - true to allow null to be injected, or false otherwise
        filter - the filter to apply to determine whether a given bean should be included (must not be null)
        Returns:
        this builder (not null)
      • build

        public BeanBag.BeanBuilder<T> build()
        Commit this supplier definition into the enclosing bean builder. Any supplier previously set on the bean builder is overwritten.
        Returns:
        the enclosing bean builder (not null)