Interface Builder


  • public interface Builder
    Mutable builder object used when building a bean context.
    • Method Detail

      • getName

        String getName()
        Return the name of the (module) context this builder is creating.
      • getProvides

        String[] getProvides()
        Return the names of module features that this module provides.
      • getDependsOn

        String[] getDependsOn()
        Return the names of modules that this module depends on.
      • setParent

        void setParent​(Builder parent)
        Set a parent builder that can provide cross-module dependencies.
      • isAddBeanFor

        boolean isAddBeanFor​(Class<?> addForType,
                             Class<?> injectTarget)
        Return true if the bean should be created and registered with the context.

        Returning false means there has been a (test double) bean already registered and that we should skip the creation and registration for this bean.

        Parameters:
        addForType - The interface that the bean implements and provides
        injectTarget - The actual bean type we are looking to create and register
      • isAddBeanFor

        boolean isAddBeanFor​(Class<?> injectTarget)
        Return true if the bean should be created and registered with the context.

        Returning false means there has been a (test double) bean already registered and that we should skip the creation and registration for this bean.

        Parameters:
        injectTarget - The actual bean type we are looking to create and register
      • register

        <T> T register​(T bean,
                       String name,
                       Class<?>... types)
        Register the bean instance into the context.

        Beans are added in an appropriate order to satisfy dependencies.

        Parameters:
        bean - The bean instance that has been created.
        name - The (optional) name of the instance.
        types - Interfaces and class level annotations this bean provides or associates to.
      • get

        <T> T get​(Class<T> cls)
        Get a dependency.
      • get

        <T> T get​(Class<T> cls,
                  String name)
        Get a named dependency.
      • getList

        <T> List<T> getList​(Class<T> interfaceType)
        Get a list of dependencies for the interface type .
      • getSet

        <T> Set<T> getSet​(Class<T> interfaceType)
        Get a set of dependencies for the interface type .
      • enrich

        <T> T enrich​(T bean,
                     Class<?>[] types)
        Return a potentially enriched bean for registration into the context. Typically for use with mockito spy.
        Parameters:
        bean - The bean with dependencies injected
        types - The types this bean registers for
        Returns:
        Either the bean or the enriched bean to register into the context.