Package io.smallrye.beanbag
Class BeanBag.BeanBuilder<T>
- java.lang.Object
-
- io.smallrye.beanbag.BeanBag.BeanBuilder<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanBag.BeanBuilder<T>addAlias(String alias)Add another name that this bean can be identified by.BeanBag.BeanBuilder<T>addRestrictedTypes(Collection<Class<? super T>> types)Restrict the types of this bean.BeanBag.Builderbuild()Commit this bean definition into the enclosing container builder.BeanBag.SupplierBuilder<T>buildSupplier()Construct a reflective supplier for this bean.BeanBag.BeanBuilder<T>setInstance(T instance)Set the supplier for this bean to a literal instance.BeanBag.BeanBuilder<T>setName(String name)Set the bean name.BeanBag.BeanBuilder<T>setPriority(int priority)Set the bean priority.BeanBag.BeanBuilder<T>setSingleton(boolean singleton)Set the singleton flag for this bean.BeanBag.BeanBuilder<T>setSupplier(BeanSupplier<T> supplier)Set the supplier for this bean.
-
-
-
Method Detail
-
setPriority
public BeanBag.BeanBuilder<T> setPriority(int priority)
Set the bean priority. Higher numbers have higher precedence. Users should normally configure beans with a priority of0or higher.- Parameters:
priority- the bean priority- Returns:
- this builder (not
null)
-
setName
public BeanBag.BeanBuilder<T> setName(String name)
Set the bean name. Beans with no name have a name of the empty string"".- Parameters:
name- the bean name (must not benull)- Returns:
- this builder (not
null)
-
addAlias
public BeanBag.BeanBuilder<T> addAlias(String alias)
Add another name that this bean can be identified by.- Parameters:
alias- the bean alias (must not benull)- Returns:
- this builder (not
null)
-
setSupplier
public BeanBag.BeanBuilder<T> setSupplier(BeanSupplier<T> supplier)
Set the supplier for this bean. Setting a supplier will overwrite a supplier created viabuildSupplier()(if any).- Parameters:
supplier- the supplier instance (must not benull)- Returns:
- this builder (not
null)
-
setInstance
public BeanBag.BeanBuilder<T> setInstance(T instance)
Set the supplier for this bean to a literal instance. Setting a supplier will overwrite a supplier created viabuildSupplier()(if any). The bean will be marked as a singleton.- Parameters:
instance- the bean instance (must not benull)- Returns:
- this builder (not
null)
-
buildSupplier
public BeanBag.SupplierBuilder<T> buildSupplier()
Construct a reflective supplier for this bean. Completing this builder will overwrite the supplier created viasetSupplier(BeanSupplier)(if any).- Returns:
- a new supplier builder (not
null)
-
setSingleton
public BeanBag.BeanBuilder<T> setSingleton(boolean singleton)
Set the singleton flag for this bean. A singleton is created in a scope which is global to a single container.- Parameters:
singleton- the value of the singleton flag- Returns:
- this builder (not
null)
-
addRestrictedTypes
public BeanBag.BeanBuilder<T> addRestrictedTypes(Collection<Class<? super T>> types)
Restrict the types of this bean. The bean will only be able to be looked up using one of these types.- Parameters:
types- the restricted types (must not benull)- Returns:
- this builder (not
null)
-
build
public BeanBag.Builder build()
Commit this bean definition into the enclosing container builder.- Returns:
- the container builder (not
null)
-
-