Class ReflectionBeanDefinition.Builder<T>

java.lang.Object
io.micronaut.reflection.ReflectionBeanDefinition.Builder<T>
Type Parameters:
T - The bean type
Enclosing class:
ReflectionBeanDefinition<T>

public static final class ReflectionBeanDefinition.Builder<T> extends Object
Builds the definition of a type, reading the class for what the builder does not set.
Since:
5.2.0
Author:
Denis Stepanov
  • Method Details

    • qualifier

      public ReflectionBeanDefinition.Builder<T> qualifier(@Nullable Qualifier<T> qualifier)
      The qualifier of the bean, overriding the qualifier annotations of the class.
      Parameters:
      qualifier - The qualifier, null to read the class
      Returns:
      This builder
    • named

      public ReflectionBeanDefinition.Builder<T> named(@Nullable String name)
      The name of the bean, as a @Named qualifier.
      Parameters:
      name - The name, null to read the class
      Returns:
      This builder
    • scope

      public ReflectionBeanDefinition.Builder<T> scope(@Nullable Class<? extends Annotation> scope)
      The scope of the bean, overriding the scope annotation of the class.
      Parameters:
      scope - The scope annotation
      Returns:
      This builder
    • singleton

      public ReflectionBeanDefinition.Builder<T> singleton(boolean 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

      public ReflectionBeanDefinition.Builder<T> exposedTypes(Class<?>... types)
      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, null to 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

      public ReflectionBeanDefinition.Builder<T> postConstruct(String... methodNames)
      The methods to invoke once the bean is created and injected, named rather than annotated: a container that names them - the initMethod of a Spring bean definition - has no annotation to read. The methods annotated @PostConstruct are 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

      public ReflectionBeanDefinition.Builder<T> preDestroy(String... methodNames)
      The methods to invoke when the bean is destroyed, named rather than annotated.
      Parameters:
      methodNames - The method names
      Returns:
      This builder
      See Also:
    • constructor

      public ReflectionBeanDefinition.Builder<T> constructor(@Nullable Constructor<T> 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

      public ReflectionBeanDefinition.Builder<T> executableMethods(Predicate<Method> executable)
      Makes the methods a predicate accepts executable methods of the bean, in addition to the ones annotated Executable. The predicate receives the non-static, non-synthetic methods of the type and its super classes.
      Parameters:
      executable - The predicate
      Returns:
      This builder
    • build

      public ReflectionBeanDefinition<T> build()
      Builds the definition.
      Returns:
      The definition
      Throws:
      IllegalArgumentException - When the type cannot be a bean