Package io.avaje.inject.spi
Interface Builder
public interface Builder
Mutable builder object used when building a bean scope.
-
Method Summary
Modifier and Type Method Description voidaddInjector(Consumer<Builder> injector)Add field and method injection.voidaddPostConstruct(Runnable runnable)Add lifecycle PostConstruct method.voidaddPreDestroy(AutoCloseable closeable)Add lifecycle PreDestroy method.BeanScopebuild(boolean withShutdownHook)Build and return the bean scope.<T> Tget(Class<T> cls)Get a dependency.<T> Tget(Class<T> cls, String name)Get a named dependency.<T> TgetNullable(Class<T> cls)Get an optional dependency potentially returning null.<T> TgetNullable(Class<T> cls, String name)Get an optional named dependency potentially returning null.<T> Optional<T>getOptional(Class<T> cls)Get an optional dependency.<T> Optional<T>getOptional(Class<T> cls, String name)Get an optional named dependency.<T> jakarta.inject.Provider<T>getProvider(Class<T> cls)Return Provider of T given the type.<T> jakarta.inject.Provider<T>getProvider(Class<T> cls, String name)Return Provider of T given the type and name.<T> jakarta.inject.Provider<T>getProviderFor(Class<?> cls, Type type)Return Provider for a generic interface type.booleanisAddBeanFor(Type... types)Return true if the bean should be created and registered with the context.booleanisAddBeanFor(String name, Type... types)Return true if the bean should be created and registered with the context.<T> List<T>list(Class<T> interfaceType)Get a list of dependencies for the interface type .static BuildernewBuilder(List<SuppliedBean> suppliedBeans, List<EnrichBean> enrichBeans, BeanScope parent)Create the root level Builder.<T> Tregister(T bean)Register the bean instance into the context.<T> TregisterPrimary(T bean)Register the bean as a Primary bean.<T> TregisterSecondary(T bean)Register the bean as a secondary bean.<T> Set<T>set(Class<T> interfaceType)Get a set of dependencies for the interface type .
-
Method Details
-
newBuilder
static Builder newBuilder(List<SuppliedBean> suppliedBeans, List<EnrichBean> enrichBeans, BeanScope parent)Create the root level Builder.- Parameters:
suppliedBeans- The list of beans (typically test doubles) supplied when building the context.enrichBeans- The list of classes we want to have with mockito spy enhancementparent- The parent BeanScope
-
isAddBeanFor
Return true if the bean should be created and registered with the context. Returning false means there has been a supplied bean already registered and that we should skip the creation and registration for this bean.- Parameters:
name- The qualifier nametypes- The types that the bean implements and provides
-
isAddBeanFor
Return true if the bean should be created and registered with the context. Returning false means there has been a supplied bean already registered and that we should skip the creation and registration for this bean.- Parameters:
types- The types that the bean implements and provides
-
register
Register the bean instance into the context.- Parameters:
bean- The bean instance that has been created.
-
registerPrimary
Register the bean as a Primary bean. -
registerSecondary
Register the bean as a secondary bean. -
addPostConstruct
Add lifecycle PostConstruct method. -
addPreDestroy
Add lifecycle PreDestroy method. -
addInjector
Add field and method injection. -
getOptional
Get an optional dependency. -
getOptional
Get an optional named dependency. -
getNullable
Get an optional dependency potentially returning null. -
getNullable
Get an optional named dependency potentially returning null. -
getProvider
Return Provider of T given the type. -
getProvider
Return Provider of T given the type and name. -
getProviderFor
Return Provider for a generic interface type.- Parameters:
cls- The usual implementation classtype- The generic interface type
-
get
Get a dependency. -
get
Get a named dependency. -
list
Get a list of dependencies for the interface type . -
set
Get a set of dependencies for the interface type . -
build
Build and return the bean scope.
-