Class BeanBag.Builder

java.lang.Object
io.smallrye.beanbag.BeanBag.Builder
Enclosing class:
BeanBag

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

    • excludePackage

      public BeanBag.Builder excludePackage(String packageName)
      Exclude beans whose Java packages start with the value of the argument.
      Parameters:
      packageName - Java package name to exclude during bean discovery
      Returns:
      this builder instance
    • includePackage

      public BeanBag.Builder includePackage(String packageName)
      Include beans whose Java packages start with the value of the argument, unless there is a matching exclude package filter. If inclusions weren't configured, all packages are assumed to be included.
      Parameters:
      packageName - Java package name to include during bean discovery
      Returns:
      this builder instance
    • isTypeFilteredOut

      public boolean isTypeFilteredOut(String type)
    • 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)