Interface BeanDefinition<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NAMED_ATTRIBUTE
      Attribute used to store a dynamic bean name.
      • Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata

        CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
      • Fields inherited from interface io.micronaut.core.annotation.AnnotationSource

        EMPTY
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      default io.micronaut.core.type.Argument<T> asArgument()  
      default <R> java.util.Optional<ExecutableMethod<T,​R>> findMethod​(java.lang.String name, java.lang.Class<?>... argumentTypes)
      Finds a single ExecutableMethod for the given name and argument types.
      default <R> java.util.stream.Stream<ExecutableMethod<T,​R>> findPossibleMethods​(java.lang.String name)
      Finds possible methods for the given method name.
      java.lang.Class<T> getBeanType()
      Returns the bean type.
      default ConstructorInjectionPoint<T> getConstructor()
      The single concrete constructor that is an injection point for creating the bean.
      default java.util.Optional<io.micronaut.core.type.Argument<?>> getContainerElement()
      If BeanType.isContainerType() returns true this will return the container element.
      default Qualifier<T> getDeclaredQualifier()
      Resolve the declared qualifier for this bean.
      default java.util.Optional<java.lang.Class<?>> getDeclaringType()  
      default java.util.Collection<ExecutableMethod<T,​?>> getExecutableMethods()  
      default java.util.Collection<FieldInjectionPoint<T,​?>> getInjectedFields()
      All the fields that require injection.
      default java.util.Collection<MethodInjectionPoint<T,​?>> getInjectedMethods()
      All methods that require injection.
      default java.lang.String getName()  
      default java.util.Collection<MethodInjectionPoint<T,​?>> getPostConstructMethods()
      All the methods that should be called once the bean has been fully initialized and constructed.
      default java.util.Collection<MethodInjectionPoint<T,​?>> getPreDestroyMethods()
      All the methods that should be called when the object is to be destroyed.
      default java.util.Collection<java.lang.Class<?>> getRequiredComponents()  
      default <R> ExecutableMethod<T,​R> getRequiredMethod​(java.lang.String name, java.lang.Class<?>... argumentTypes)
      Finds a single ExecutableMethod for the given name and argument types.
      default java.util.Optional<java.lang.Class<? extends java.lang.annotation.Annotation>> getScope()  
      default java.util.Optional<java.lang.String> getScopeName()  
      default java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments()
      If the bean itself declares any type arguments this method will return the classes that represent those types.
      default java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments​(java.lang.Class<?> type)
      Return the type arguments for the given interface or super type for this bean.
      default java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments​(java.lang.String type)
      Return the type arguments for the given interface or super type for this bean.
      default java.lang.Class<?>[] getTypeParameters()
      Returns the type parameters as a class array for the bean type.
      default java.lang.Class<?>[] getTypeParameters​(java.lang.Class<?> type)
      Returns the type parameters as a class array for the given type.
      default T inject​(BeanContext context, T bean)
      Inject the given bean with the context.
      default T inject​(BeanResolutionContext resolutionContext, BeanContext context, T bean)
      Inject the given bean with the context.
      default boolean isAbstract()  
      default boolean isCandidateBean​(io.micronaut.core.type.Argument<?> beanType)
      Return whether this bean type is a candidate for dependency injection for the passed type.
      default boolean isIterable()  
      default boolean isProvided()
      Deprecated.
      Provided beans are deprecated
      default boolean isProxy()
      Whether this bean definition represents a proxy.
      default boolean isSingleton()  
      default Qualifier<T> resolveDynamicQualifier()  
      • Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata

        getAnnotationValuesByName, getAnnotationValuesByStereotype, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
      • Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate

        booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
      • Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider

        getAnnotationMetadata
    • Field Detail

      • NAMED_ATTRIBUTE

        static final java.lang.String NAMED_ATTRIBUTE
        Attribute used to store a dynamic bean name.
    • Method Detail

      • getScope

        default java.util.Optional<java.lang.Class<? extends java.lang.annotation.Annotation>> getScope()
        Returns:
        The scope of the bean
      • getScopeName

        default java.util.Optional<java.lang.String> getScopeName()
        Returns:
        The name of the scope
      • isSingleton

        default boolean isSingleton()
        Returns:
        Whether the scope is singleton
      • getContainerElement

        default java.util.Optional<io.micronaut.core.type.Argument<?>> getContainerElement()
        If BeanType.isContainerType() returns true this will return the container element.
        Returns:
        The container element.
      • isCandidateBean

        default boolean isCandidateBean​(@Nullable
                                        io.micronaut.core.type.Argument<?> beanType)
        Description copied from interface: BeanType
        Return whether this bean type is a candidate for dependency injection for the passed type.
        Specified by:
        isCandidateBean in interface BeanType<T>
        Parameters:
        beanType - The bean type
        Returns:
        True if it is
      • isProvided

        @Deprecated
        default boolean isProvided()
        Deprecated.
        Provided beans are deprecated
        Returns:
        Is this definition provided by another bean
        See Also:
        Provided
      • isIterable

        default boolean isIterable()
        Returns:
        Whether the bean declared with EachProperty or EachBean
      • getBeanType

        java.lang.Class<T> getBeanType()
        Description copied from interface: BeanType
        Returns the bean type.
        Specified by:
        getBeanType in interface BeanType<T>
        Returns:
        The produced bean type
      • getDeclaringType

        default java.util.Optional<java.lang.Class<?>> getDeclaringType()
        Returns:
        The type that declares this definition, null if not applicable.
      • getConstructor

        default ConstructorInjectionPoint<T> getConstructor()
        The single concrete constructor that is an injection point for creating the bean.
        Returns:
        The constructor injection point
      • getRequiredComponents

        default java.util.Collection<java.lang.Class<?>> getRequiredComponents()
        Returns:
        All required components for this entity definition
      • getInjectedMethods

        default java.util.Collection<MethodInjectionPoint<T,​?>> getInjectedMethods()
        All methods that require injection. This is a subset of all the methods in the class.
        Returns:
        The required properties
      • getInjectedFields

        default java.util.Collection<FieldInjectionPoint<T,​?>> getInjectedFields()
        All the fields that require injection.
        Returns:
        The required fields
      • getPostConstructMethods

        default java.util.Collection<MethodInjectionPoint<T,​?>> getPostConstructMethods()
        All the methods that should be called once the bean has been fully initialized and constructed.
        Returns:
        Methods to call post construct
      • getPreDestroyMethods

        default java.util.Collection<MethodInjectionPoint<T,​?>> getPreDestroyMethods()
        All the methods that should be called when the object is to be destroyed.
        Returns:
        Methods to call pre-destroy
      • getName

        @NonNull
        default java.lang.String getName()
        Specified by:
        getName in interface BeanType<T>
        Specified by:
        getName in interface io.micronaut.core.naming.Named
        Returns:
        The class name
      • findMethod

        default <R> java.util.Optional<ExecutableMethod<T,​R>> findMethod​(java.lang.String name,
                                                                               java.lang.Class<?>... argumentTypes)
        Finds a single ExecutableMethod for the given name and argument types.
        Type Parameters:
        R - The return type
        Parameters:
        name - The method name
        argumentTypes - The argument types
        Returns:
        An optional ExecutableMethod
      • findPossibleMethods

        default <R> java.util.stream.Stream<ExecutableMethod<T,​R>> findPossibleMethods​(java.lang.String name)
        Finds possible methods for the given method name.
        Type Parameters:
        R - The return type
        Parameters:
        name - The method name
        Returns:
        The possible methods
      • inject

        default T inject​(BeanContext context,
                         T bean)
        Inject the given bean with the context.
        Parameters:
        context - The context
        bean - The bean
        Returns:
        The injected bean
      • inject

        default T inject​(BeanResolutionContext resolutionContext,
                         BeanContext context,
                         T bean)
        Inject the given bean with the context.
        Parameters:
        resolutionContext - the resolution context
        context - The context
        bean - The bean
        Returns:
        The injected bean
      • asArgument

        @NonNull
        default io.micronaut.core.type.Argument<T> asArgument()
        Specified by:
        asArgument in interface io.micronaut.core.type.ArgumentCoercible<T>
      • isProxy

        default boolean isProxy()
        Whether this bean definition represents a proxy.
        Returns:
        True if it represents a proxy
      • getTypeArguments

        @NonNull
        default java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments()
        If the bean itself declares any type arguments this method will return the classes that represent those types.
        Returns:
        The type arguments
      • getTypeArguments

        @NonNull
        default java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments​(java.lang.Class<?> type)
        Return the type arguments for the given interface or super type for this bean.
        Parameters:
        type - The super class or interface type
        Returns:
        The type arguments
      • getTypeParameters

        @NonNull
        default java.lang.Class<?>[] getTypeParameters​(@Nullable
                                                       java.lang.Class<?> type)
        Returns the type parameters as a class array for the given type.
        Parameters:
        type - The type
        Returns:
        The type parameters
      • getTypeParameters

        @NonNull
        default java.lang.Class<?>[] getTypeParameters()
        Returns the type parameters as a class array for the bean type.
        Returns:
        The type parameters for the bean type as a class array.
      • getTypeArguments

        @NonNull
        default java.util.List<io.micronaut.core.type.Argument<?>> getTypeArguments​(java.lang.String type)
        Return the type arguments for the given interface or super type for this bean.
        Parameters:
        type - The super class or interface type
        Returns:
        The type arguments
      • getRequiredMethod

        default <R> ExecutableMethod<T,​R> getRequiredMethod​(java.lang.String name,
                                                                  java.lang.Class<?>... argumentTypes)
        Finds a single ExecutableMethod for the given name and argument types.
        Type Parameters:
        R - The return type
        Parameters:
        name - The method name
        argumentTypes - The argument types
        Returns:
        An optional ExecutableMethod
        Throws:
        java.lang.IllegalStateException - If the method cannot be found
      • isAbstract

        default boolean isAbstract()
        Returns:
        Whether the bean definition is abstract
      • getDeclaredQualifier

        @Nullable
        default Qualifier<T> getDeclaredQualifier()
        Resolve the declared qualifier for this bean.
        Returns:
        The qualifier or null if this isn't one
      • resolveDynamicQualifier

        @Nullable
        default Qualifier<T> resolveDynamicQualifier()
        Returns:
        Method that can be overridden to resolve a dynamic qualifier