Class ReflectionBeanDefinition.Builder<T>
java.lang.Object
io.micronaut.reflection.ReflectionBeanDefinition.Builder<T>
- Type Parameters:
T- The bean type
- Enclosing class:
ReflectionBeanDefinition<T>
Builds the definition of a type, reading the class for what the builder does not set.
- Since:
- 5.2.0
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptionadditionalAnnotationMetadata(@Nullable AnnotationMetadata annotationMetadata) The annotations the bean carries beyond the ones its class declares, both of them declared: a container adapting another one - a Spring bean it marks primary, a Guice binding it qualifies - adds its own without losing what the class says.annotationMetadata(@Nullable AnnotationMetadata annotationMetadata) The annotation metadata of the bean, replacing the one read from the annotations of the class.build()Builds the definition.constructor(@Nullable Constructor<T> constructor) The constructor the bean is instantiated with, overriding the selection from the constructors of the class.executableMethods(Predicate<Method> executable) Makes the methods a predicate accepts executable methods of the bean, in addition to the ones annotatedExecutable.exposedTypes(Class<?>... types) Limits the types the bean is exposed as, overriding the@Bean(typed = ...)annotation of the class.The name of the bean, as a@Namedqualifier.postConstruct(String... methodNames) The methods to invoke once the bean is created and injected, named rather than annotated: a container that names them - theinitMethodof a Spring bean definition - has no annotation to read.preDestroy(String... methodNames) The methods to invoke when the bean is destroyed, named rather than annotated.The qualifier of the bean, overriding the qualifier annotations of the class.scope(@Nullable Class<? extends Annotation> scope) The scope of the bean, overriding the scope annotation of the class.singleton(boolean singleton) Whether the bean is a singleton, overriding what the scope annotation of the class says.
-
Method Details
-
qualifier
The qualifier of the bean, overriding the qualifier annotations of the class.- Parameters:
qualifier- The qualifier,nullto read the class- Returns:
- This builder
-
named
The name of the bean, as a@Namedqualifier.- Parameters:
name- The name,nullto read the class- Returns:
- This builder
-
scope
The scope of the bean, overriding the scope annotation of the class.- Parameters:
scope- The scope annotation- Returns:
- This builder
-
singleton
Whether the bean is a singleton, overriding what the scope annotation of the class says.- Parameters:
singleton- Whether the bean is a singleton- Returns:
- This builder
-
exposedTypes
Limits the types the bean is exposed as, overriding the@Bean(typed = ...)annotation of the class.- Parameters:
types- The exposed types, each a super type of the bean type- Returns:
- This builder
-
annotationMetadata
public ReflectionBeanDefinition.Builder<T> annotationMetadata(@Nullable AnnotationMetadata annotationMetadata) The annotation metadata of the bean, replacing the one read from the annotations of the class.- Parameters:
annotationMetadata- The metadata,nullto read the class- Returns:
- This builder
-
additionalAnnotationMetadata
public ReflectionBeanDefinition.Builder<T> additionalAnnotationMetadata(@Nullable AnnotationMetadata annotationMetadata) The annotations the bean carries beyond the ones its class declares, both of them declared: a container adapting another one - a Spring bean it marks primary, a Guice binding it qualifies - adds its own without losing what the class says.- Parameters:
annotationMetadata- The annotations to add- Returns:
- This builder
-
postConstruct
The methods to invoke once the bean is created and injected, named rather than annotated: a container that names them - theinitMethodof a Spring bean definition - has no annotation to read. The methods annotated@PostConstructare invoked as well, and the arguments of a named method are injected as those of an annotated one are.- Parameters:
methodNames- The method names- Returns:
- This builder
-
preDestroy
The methods to invoke when the bean is destroyed, named rather than annotated.- Parameters:
methodNames- The method names- Returns:
- This builder
- See Also:
-
constructor
The constructor the bean is instantiated with, overriding the selection from the constructors of the class.- Parameters:
constructor- The constructor- Returns:
- This builder
-
executableMethods
Makes the methods a predicate accepts executable methods of the bean, in addition to the ones annotatedExecutable. The predicate receives the non-static, non-synthetic methods of the type and its super classes.- Parameters:
executable- The predicate- Returns:
- This builder
-
build
Builds the definition.- Returns:
- The definition
- Throws:
IllegalArgumentException- When the type cannot be a bean
-