Class ExecutableMethodsDefinitionWriter
java.lang.Object
io.micronaut.inject.writer.ExecutableMethodsDefinitionWriter
- All Implemented Interfaces:
Buildable<OutputObjectDef>
@NullUnmarked
@Internal
public class ExecutableMethodsDefinitionWriter
extends Object
implements Buildable<OutputObjectDef>
Writes out a
ExecutableMethodsDefinition class.- Since:
- 3.0
- Author:
- Denis Stepanov
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionExecutableMethodsDefinitionWriter(EvaluatedExpressionProcessor evaluatedExpressionProcessor, AnnotationMetadata annotationMetadataWithDefaults, String beanDefinitionClassName, String beanDefinitionReferenceClassName, OriginatingElements originatingElements) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddBridgeMethod(MethodElement methodElement, MethodElement proxyMethod) voidaddExecutableMethod(TypedElement declaringType, MethodElement methodElement) Adds the given method to the executable methods definition.intaddLifecycleMethod(TypedElement declaringType, MethodElement methodElement, boolean postConstruct) Adds a@PostConstructor@PreDestroycallback of the bean so that it is dispatched, without reflection, through this definition.final OutputObjectDefbuild()Invoke to build the class model.final intfindIndexOfExecutableMethod(MethodElement methodElement) io.micronaut.sourcegen.model.ClassTypeDefgetMethodByIndex(int index) Retrieves the `MethodElement` at the specified index.intRetrieves the total count of methods.booleanisLifecycleMethod(int index) Whether the method at the given index is a lifecycle callback added throughaddLifecycleMethod(TypedElement, MethodElement, boolean).booleanDoes method support intercepted proxy.booleanBy default, when theBeanContextis started, theExecutableMethodProcessorinstances unless this method returns true.voidsetProxyType(@Nullable io.micronaut.sourcegen.model.ClassTypeDef proxyType)
-
Field Details
-
CLASS_SUFFIX
- See Also:
-
GET_EXECUTABLE_AT_INDEX_METHOD
-
REQUIRES_METHOD_PROCESSING_METHOD
-
-
Constructor Details
-
ExecutableMethodsDefinitionWriter
public ExecutableMethodsDefinitionWriter(EvaluatedExpressionProcessor evaluatedExpressionProcessor, AnnotationMetadata annotationMetadataWithDefaults, String beanDefinitionClassName, String beanDefinitionReferenceClassName, OriginatingElements originatingElements)
-
-
Method Details
-
requiresMethodProcessing
public boolean requiresMethodProcessing()By default, when theBeanContextis started, theExecutableMethodProcessorinstances unless this method returns true.- Returns:
- Whether the bean definition requires method processing
- See Also:
-
setProxyType
public void setProxyType(@Nullable io.micronaut.sourcegen.model.ClassTypeDef proxyType) - Parameters:
proxyType- The proxy type
-
getClassName
- Returns:
- The generated class name.
-
getClassTypeDef
public io.micronaut.sourcegen.model.ClassTypeDef getClassTypeDef()- Returns:
- The generated class type.
-
isSupportsInterceptedProxy
public boolean isSupportsInterceptedProxy()Does method support intercepted proxy.- Returns:
- Does method support intercepted proxy
-
addExecutableMethod
Adds the given method to the executable methods definition.- Parameters:
declaringType- The declaring typemethodElement- The method element
-
addLifecycleMethod
public int addLifecycleMethod(TypedElement declaringType, MethodElement methodElement, boolean postConstruct) Adds a@PostConstructor@PreDestroycallback of the bean so that it is dispatched, without reflection, through this definition.A callback added here is deliberately not an executable method of the bean: it is excluded from
ExecutableMethodsDefinition.getExecutableMethods()and never marked for startup processing, so executable method processors and adapters do not observe it. It is only reachable throughExecutableMethodsDefinition.getPostConstructExecutableMethods()andExecutableMethodsDefinition.getPreDestroyExecutableMethods(), at the returned position.- Parameters:
declaringType- The declaring typemethodElement- The callbackpostConstruct-truefor a post-construct callback,falsefor a pre-destroy one- Returns:
- The position of the callback among the callbacks of its kind
- Since:
- 5.2.0
-
isLifecycleMethod
public boolean isLifecycleMethod(int index) Whether the method at the given index is a lifecycle callback added throughaddLifecycleMethod(TypedElement, MethodElement, boolean).- Parameters:
index- The index- Returns:
trueif the method is a lifecycle callback- Since:
- 5.2.0
-
addBridgeMethod
-
findIndexOfExecutableMethod
-
build
Invoke to build the class model.- Specified by:
buildin interfaceBuildable<OutputObjectDef>- Returns:
- The builder result
-
getMethodsCount
public int getMethodsCount()Retrieves the total count of methods.- Returns:
- The number of methods available.
- Since:
- 5.0
-
getMethodByIndex
Retrieves the `MethodElement` at the specified index.- Parameters:
index- The index of the method to retrieve.- Returns:
- The `MethodElement` corresponding to the specified index.
- Since:
- 5.0
-