Interface BeanDefinition<T>

Type Parameters:
T - The bean type
All Superinterfaces:
AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, ArgumentCoercible<T>, BeanContextConditional, BeanInfo<T>, BeanType<T>, Named, QualifiedBeanType<T>
All Known Subinterfaces:
DelegatingBeanDefinition<T>, DisposableBeanDefinition<T>, InitializingBeanDefinition<T>, InjectableBeanDefinition<T>, InstantiatableBeanDefinition<T>, ParametrizedInstantiatableBeanDefinition<T>, ProxyBeanDefinition<T>, RuntimeBeanDefinition<T>, ValidatedBeanDefinition<T>
All Known Implementing Classes:
AbstractInitializableBeanDefinition, AbstractProviderDefinition, ApplicationEventPublisherFactory, BeanProviderDefinition, DisabledBean, InterceptorRegistryBean, JakartaProviderBeanDefinition, JavaxProviderBeanDefinition

public interface BeanDefinition<T> extends QualifiedBeanType<T>, Named, BeanType<T>, ArgumentCoercible<T>
Defines a bean definition and its requirements. A bean definition must have a singled injectable constructor or a no-args constructor.
Since:
1.0
Author:
Graeme Rocher
  • Method Details

    • getScope

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

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

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

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

      default boolean isCandidateBean(@Nullable @Nullable 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
    • isIterable

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

      default boolean isConfigurationProperties()
      Returns:
      Is the type configuration properties.
    • getBeanType

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

      default Optional<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 Collection<Class<?>> getRequiredComponents()
      Returns:
      All required components for this entity definition
    • getInjectedMethods

      default 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 Collection<FieldInjectionPoint<T,?>> getInjectedFields()
      All the fields that require injection.
      Returns:
      The required fields
    • getPostConstructMethods

      default 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 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 @NonNull String getName()
      Specified by:
      getName in interface BeanType<T>
      Specified by:
      getName in interface Named
      Returns:
      The class name
    • findMethod

      default <R> Optional<ExecutableMethod<T,R>> findMethod(String name, 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> Stream<ExecutableMethod<T,R>> findPossibleMethods(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
    • getExecutableMethods

      default Collection<ExecutableMethod<T,?>> getExecutableMethods()
      Returns:
      The ExecutableMethod instances for this definition
    • asArgument

      @NonNull default @NonNull Argument<T> asArgument()
      Specified by:
      asArgument in interface ArgumentCoercible<T>
      Specified by:
      asArgument in interface BeanInfo<T>
      Returns:
      The argument
    • isProxy

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

      @NonNull default @NonNull List<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 @NonNull List<Argument<?>> getTypeArguments(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 @NonNull Class<?>[] getTypeParameters(@Nullable @Nullable 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 @NonNull 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 @NonNull List<Argument<?>> getTypeArguments(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(String name, 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:
      IllegalStateException - If the method cannot be found
    • isAbstract

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

      default Argument<T> getGenericBeanType()
      Specified by:
      getGenericBeanType in interface BeanInfo<T>
      Returns:
      The generic bean type
    • getDeclaredQualifier

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

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