Package io.micronaut.inject.ast
Interface MethodElement
-
- All Superinterfaces:
io.micronaut.core.annotation.AnnotatedElement
,io.micronaut.core.annotation.AnnotationMetadata
,io.micronaut.core.annotation.AnnotationMetadataDelegate
,io.micronaut.core.annotation.AnnotationMetadataProvider
,io.micronaut.core.annotation.AnnotationSource
,io.micronaut.core.naming.Described
,Element
,MemberElement
,io.micronaut.core.naming.Named
- All Known Subinterfaces:
BeanConstructorElement
,BeanMethodElement
,ConstructorElement
public interface MethodElement extends MemberElement
Stores data about an element that references a method.- Since:
- 1.0
-
-
Field Summary
-
Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
-
Fields inherited from interface io.micronaut.inject.ast.Element
EMPTY_ELEMENT_ARRAY
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BeanElementBuilder
addAssociatedBean(ClassElement type)
This method adds an associated bean using this method element as the originating element.default java.util.List<? extends GenericPlaceholderElement>
getDeclaredTypeVariables()
default java.lang.String
getDescription(boolean simple)
Get the method description.default ClassElement
getGenericReturnType()
The generic return type of the method.ParameterElement[]
getParameters()
default java.util.Optional<ClassElement>
getReceiverType()
Returns the receiver type of this executable, or empty if the method has no receiver type.ClassElement
getReturnType()
default ParameterElement[]
getSuspendParameters()
IfisSuspend()
returns true this method exposes the continuation parameter in addition to the other parameters of the method.default ClassElement[]
getThrownTypes()
Returns the types declared in thethrows
declaration of a method.default boolean
hasParameters()
Returns true if the method has parameters.default boolean
isDefault()
Is the method a default method on an interfaces.default boolean
isSuspend()
Is the method a Kotlin suspend function.static MethodElement
of(ClassElement declaredType, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, ClassElement returnType, ClassElement genericReturnType, java.lang.String name, ParameterElement... parameterElements)
Creates aMethodElement
for the given parameters.default boolean
overrides(MethodElement overridden)
Checks if this method element overrides another.MethodElement
withNewParameters(ParameterElement... newParameters)
Takes this method element and transforms into a new method element with the given parameters appended to the existing parameters.-
Methods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
-
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
-
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, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotype
-
Methods inherited from interface io.micronaut.inject.ast.MemberElement
getDeclaringType, getModifiers, getOwningType, isAccessible, isAccessible, isReflectionRequired, isReflectionRequired
-
-
-
-
Method Detail
-
getReturnType
@NonNull ClassElement getReturnType()
- Returns:
- The return type of the method
-
getDeclaredTypeVariables
default java.util.List<? extends GenericPlaceholderElement> getDeclaredTypeVariables()
- Returns:
- The type arguments declared on this method.
-
getReceiverType
default java.util.Optional<ClassElement> 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
@NonNull default ClassElement[] getThrownTypes()
Returns the types declared in thethrows
declaration of a method.- Returns:
- The
throws
types, if any. Nevernull
. - Since:
- 3.1.0
-
getParameters
@NonNull ParameterElement[] getParameters()
- Returns:
- The method parameters
-
withNewParameters
@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.- Parameters:
newParameters
- The new parameters- Returns:
- A new method element
- Since:
- 2.3.0
-
addAssociatedBean
@NonNull default BeanElementBuilder addAssociatedBean(@NonNull ClassElement type)
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
@NonNull default ParameterElement[] 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
-
getGenericReturnType
@NonNull default ClassElement getGenericReturnType()
The generic return type of the method.- Returns:
- The return type of the method
- Since:
- 1.1.1
-
getDescription
@NonNull default java.lang.String getDescription(boolean simple)
Get the method description.- Specified by:
getDescription
in interfaceio.micronaut.core.naming.Described
- Specified by:
getDescription
in interfaceElement
- Parameters:
simple
- If simple type names are to be used- Returns:
- The method description
-
overrides
default boolean overrides(@NonNull MethodElement overridden)
Checks if this method element overrides another.- Parameters:
overridden
- Possible overridden method- Returns:
- true if this overrides passed method element
- Since:
- 3.1
-
of
@NonNull static MethodElement of(@NonNull ClassElement declaredType, @NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @NonNull ClassElement returnType, @NonNull ClassElement genericReturnType, @NonNull java.lang.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
-
-