Package io.micronaut.inject.ast
Interface MethodElement
- All Superinterfaces:
AnnotatedElement
,AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,Described
,Element
,MemberElement
,MutableAnnotationMetadataDelegate<Element>
,Named
- All Known Subinterfaces:
BeanConstructorElement
,BeanMethodElement
,ConstructorElement
- All Known Implementing Classes:
GroovyConstructorElement
,GroovyMethodElement
,JavaMethodElement
Stores data about an element that references a method.
- Since:
- 1.0
- Author:
- James Kleeh
-
Field Summary
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
Fields inherited from interface io.micronaut.inject.ast.Element
EMPTY_ELEMENT_ARRAY
Fields inherited from interface io.micronaut.inject.ast.annotation.MutableAnnotationMetadataDelegate
EMPTY
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull BeanElementBuilder
This method adds an associated bean using this method element as the originating element.default @NonNull Map<String,
ClassElement> The declared type arguments for this method element.default List<? extends GenericPlaceholderElement>
getDescription
(boolean simple) Get the method description.default @NonNull ClassElement
The generic return type of the method.Returns the method annotations.default Optional<ClassElement>
Returns the receiver type of this executable, or empty if the method has no receiver type.default @NonNull ParameterElement[]
IfisSuspend()
returns true this method exposes the continuation parameter in addition to the other parameters of the method.default @NonNull ClassElement[]
Returns the types declared in thethrows
declaration of a method.default @NonNull Map<String,
ClassElement> The type arguments for this method element.default boolean
Returns true if the method has parameters.default boolean
hides
(@NonNull MemberElement memberElement) Checks if this member element hides another.default boolean
Is the method a default method on an interfaces.default boolean
Is the method a Kotlin suspend function.default boolean
If method has varargs parameter.static @NonNull MethodElement
of
(@NonNull ClassElement declaredType, @NonNull AnnotationMetadata annotationMetadata, @NonNull ClassElement returnType, @NonNull ClassElement genericReturnType, @NonNull String name, ParameterElement... parameterElements) Creates aMethodElement
for the given parameters.static @NonNull MethodElement
of
(@NonNull ClassElement owningType, @NonNull ClassElement declaringType, @NonNull AnnotationMetadataProvider methodAnnotationMetadataProvider, @NonNull AnnotationMetadataProvider annotationMetadataProvider, @NonNull AbstractAnnotationMetadataBuilder<?, ?> metadataBuilder, @NonNull ClassElement returnType, @NonNull ClassElement genericReturnType, @NonNull String name, boolean isStatic, boolean isFinal, ParameterElement... parameterElements) Creates aMethodElement
for the given parameters.default boolean
overrides
(@NonNull MethodElement overridden) Checks if this method element overrides another.default MethodElement
withAnnotationMetadata
(AnnotationMetadata annotationMetadata) Copies this element and overrides its annotations.default @NonNull MethodElement
withNewOwningType
(@NonNull ClassElement owningType) Returns a new method with a new owning type.default @NonNull MethodElement
withNewParameters
(@NonNull ParameterElement... newParameters) Takes this method element and transforms into a new method element with the given parameters appended to the existing parameters.withParameters
(@NonNull ParameterElement... newParameters) Takes this method element and transforms into a new method element with the given parameters.Methods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresent
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, copyAnnotationMetadata, 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, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getTargetAnnotationMetadata, 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
Methods inherited from interface io.micronaut.inject.ast.Element
annotate, annotate, annotate, annotate, annotate, getDescription, getDocumentation, getName, getNativeType, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotype
Methods inherited from interface io.micronaut.inject.ast.MemberElement
getDeclaringType, getModifiers, getOwningType, isAccessible, isAccessible, isReflectionRequired, isReflectionRequired
-
Method Details
-
getMethodAnnotationMetadata
@NonNull default @NonNull MutableAnnotationMetadataDelegate<AnnotationMetadata> getMethodAnnotationMetadata()Returns the method annotations. The method will only return annotations defined on a method or inherited from the super methods, whileAnnotationMetadataProvider.getAnnotationMetadata()
for a method combines the class and the method annotations. NOTE: For a constructorAnnotationMetadataProvider.getAnnotationMetadata()
will not combine the class annotations.- Returns:
- The method annotation metadata
- Since:
- 4.0.0
-
getReturnType
- Returns:
- The return type of the method
-
getDeclaredTypeVariables
- Returns:
- The type arguments declared on this method.
-
getTypeArguments
The type arguments for this method element. The type arguments should include the type arguments added to the method plus the type arguments of the declaring class.- Returns:
- The type arguments for this method element
- Since:
- 4.0.0
-
getDeclaredTypeArguments
The declared type arguments for this method element.- Returns:
- The declared type arguments for this method element
- Since:
- 4.0.0
-
getReceiverType
Returns the receiver type of this executable, or empty if the method has no receiver type.
A MethodElement which is an instance method, or a constructor of an inner class, has a receiver type derived from the declaring type.
A MethodElement which is a static method, or a constructor of a non-inner class, or an initializer (static or instance), has no receiver type.
- Returns:
- The receiver type for the method if one exists.
- Since:
- 3.1.0
-
getThrownTypes
Returns the types declared in thethrows
declaration of a method.- Returns:
- The
throws
types, if any. Nevernull
. - Since:
- 3.1.0
-
getParameters
- Returns:
- The method parameters
-
withNewParameters
@NonNull default @NonNull MethodElement withNewParameters(@NonNull @NonNull ParameterElement... newParameters) Takes this method element and transforms into a new method element with the given parameters appended to the existing parameters.- Parameters:
newParameters
- The new parameters- Returns:
- A new method element
- Since:
- 2.3.0
-
withParameters
Takes this method element and transforms into a new method element with the given parameters.- Parameters:
newParameters
- The new parameters- Returns:
- A new method element
- Since:
- 4.0.0
-
withNewOwningType
@NonNull default @NonNull MethodElement withNewOwningType(@NonNull @NonNull ClassElement owningType) Returns a new method with a new owning type.- Parameters:
owningType
- The owning type.- Returns:
- A new method element
- Since:
- 4.0.0
-
addAssociatedBean
This method adds an associated bean using this method element as the originating element.Note that this method can only be called on classes being directly compiled by Micronaut. If the ClassElement is loaded from pre-compiled code an
UnsupportedOperationException
will be thrown.- Parameters:
type
- The type of the bean- Returns:
- A bean builder
-
getSuspendParameters
IfisSuspend()
returns true this method exposes the continuation parameter in addition to the other parameters of the method.- Returns:
- The suspend parameters
- Since:
- 2.3.0
-
hasParameters
default boolean hasParameters()Returns true if the method has parameters.- Returns:
- True if it does
-
isSuspend
default boolean isSuspend()Is the method a Kotlin suspend function.- Returns:
- True if it is.
- Since:
- 2.3.0
-
isDefault
default boolean isDefault()Is the method a default method on an interfaces.- Returns:
- True if it is.
- Since:
- 2.3.0
-
isVarArgs
default boolean isVarArgs()If method has varargs parameter.- Returns:
- True if it does
- Since:
- 4.0.0
-
getGenericReturnType
The generic return type of the method.- Returns:
- The return type of the method
- Since:
- 1.1.1
-
getDescription
Get the method description.- Specified by:
getDescription
in interfaceDescribed
- Specified by:
getDescription
in interfaceElement
- Parameters:
simple
- If simple type names are to be used- Returns:
- The method description
-
overrides
Checks if this method element overrides another.- Parameters:
overridden
- Possible overridden method- Returns:
- true if this overrides passed method element
- Since:
- 3.1
-
hides
Description copied from interface:MemberElement
Checks if this member element hides another.- Specified by:
hides
in interfaceMemberElement
- Parameters:
memberElement
- The possibly hidden element- Returns:
- true if this member element hides passed field element
-
of
@NonNull static @NonNull MethodElement of(@NonNull @NonNull ClassElement declaredType, @NonNull @NonNull AnnotationMetadata annotationMetadata, @NonNull @NonNull ClassElement returnType, @NonNull @NonNull ClassElement genericReturnType, @NonNull @NonNull String name, ParameterElement... parameterElements) Creates aMethodElement
for the given parameters.- Parameters:
declaredType
- The declaring typeannotationMetadata
- The annotation metadatareturnType
- The return typegenericReturnType
- The generic return typename
- The nameparameterElements
- The parameter elements- Returns:
- The method element
-
of
@NonNull static @NonNull MethodElement of(@NonNull @NonNull ClassElement owningType, @NonNull @NonNull ClassElement declaringType, @NonNull @NonNull AnnotationMetadataProvider methodAnnotationMetadataProvider, @NonNull @NonNull AnnotationMetadataProvider annotationMetadataProvider, @NonNull @NonNull AbstractAnnotationMetadataBuilder<?, ?> metadataBuilder, @NonNull @NonNull ClassElement returnType, @NonNull @NonNull ClassElement genericReturnType, @NonNull @NonNull String name, boolean isStatic, boolean isFinal, ParameterElement... parameterElements) Creates aMethodElement
for the given parameters.- Parameters:
owningType
- The owing typedeclaringType
- The declaring typemethodAnnotationMetadataProvider
- The method annotation metadata providerannotationMetadataProvider
- The annotation metadata providermetadataBuilder
- The metadata builderreturnType
- The return typegenericReturnType
- The generic return typename
- The nameisStatic
- Is staticisFinal
- Is finalparameterElements
- The parameter elements- Returns:
- The method element
- Since:
- 4.0.0
-
withAnnotationMetadata
Description copied from interface:Element
Copies this element and overrides its annotations.- Specified by:
withAnnotationMetadata
in interfaceElement
- Specified by:
withAnnotationMetadata
in interfaceMemberElement
- Parameters:
annotationMetadata
- The annotation metadata- Returns:
- A new element
-