java.lang.Object
io.smallrye.beanbag.BeanBag.BeanBuilder<T>
- Type Parameters:
T- the bean type
- Enclosing class:
BeanBag
A builder for an individual bean's configuration.
-
Method Summary
Modifier and TypeMethodDescriptionAdd another name that this bean can be identified by.addRestrictedTypes(Collection<Class<? super T>> types) Restrict the types of this bean.build()Commit this bean definition into the enclosing container builder.Construct a reflective supplier for this bean.setInstance(T instance) Set the supplier for this bean to a literal instance.Set the bean name.setPriority(int priority) Set the bean priority.setSingleton(boolean singleton) Set the singleton flag for this bean.setSupplier(BeanSupplier<T> supplier) Set the supplier for this bean.
-
Method Details
-
setPriority
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
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
Add another name that this bean can be identified by.- Parameters:
alias- the bean alias (must not benull)- Returns:
- this builder (not
null)
-
setSupplier
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
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
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
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
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
Commit this bean definition into the enclosing container builder.- Returns:
- the container builder (not
null)
-