Class BeanBag.Builder

  • Enclosing class:
    BeanBag

    public static final class BeanBag.Builder
    extends Object
    A builder for a new container.
    • Method Detail

      • addBean

        public <T> BeanBag.BeanBuilder<T> addBean​(Class<T> type)
        Add a new bean with the given type, returning a builder to configure it. The given type must be the concrete type of the bean or a class representing a supertype of that concrete type.
        Type Parameters:
        T - the bean type
        Parameters:
        type - the bean type class (must not be null)
        Returns:
        the bean builder (not null)
      • addBeanInstance

        public <T> BeanBag.Builder addBeanInstance​(T bean)
        Add a new bean which resolves to the given instance.
        Type Parameters:
        T - the bean type
        Parameters:
        bean - the bean instance (must not be null)
        Returns:
        this builder (not null)
      • build

        public BeanBag build()
        Build a new container instance with the beans that were previously configured in this builder.
        Returns:
        the new container (not null)