Class JavaMethodElement
java.lang.Object
io.micronaut.inject.ast.annotation.AbstractAnnotationElement
io.micronaut.annotation.processing.visitor.AbstractJavaElement
io.micronaut.annotation.processing.visitor.JavaMethodElement
- All Implemented Interfaces:
AnnotatedElement
,AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,Described
,Named
,MutableAnnotationMetadataDelegate<Element>
,Element
,MemberElement
,MethodElement
A method element returning data from a
ExecutableElement
.- Since:
- 1.0
- Author:
- James Kleeh
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ExecutableElement
protected final JavaClassElement
Fields inherited from class io.micronaut.annotation.processing.visitor.AbstractJavaElement
visitorContext
Fields inherited from class io.micronaut.inject.ast.annotation.AbstractAnnotationElement
elementAnnotationMetadataFactory, presetAnnotationMetadata
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
-
Constructor Summary
ConstructorDescriptionJavaMethodElement
(JavaClassElement owningType, JavaNativeElement.Method nativeElement, ElementAnnotationMetadataFactory annotationMetadataFactory, JavaVisitorContext visitorContext) -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractJavaElement
copyThis()
protected void
copyValues
(AbstractJavaElement element) Supplies the metadata.protected MutableAnnotationMetadataDelegate<?>
Get annotation metadata to add or remove annotations.The declared type arguments for this method element.List<? extends GenericPlaceholderElement>
The generic return type of the method.Returns the method annotations.Returns the native underlying type.The owing type is the type that owns this element.Returns the receiver type of this executable, or empty if the method has no receiver type.IfMethodElement.isSuspend()
returns true this method exposes the continuation parameter in addition to the other parameters of the method.Returns the types declared in thethrows
declaration of a method.The type arguments for this method element.boolean
hides
(MemberElement hidden) Checks if this member element hides another.boolean
Is the method a default method on an interfaces.boolean
Is the method a Kotlin suspend function.boolean
If method has varargs parameter.protected @NonNull io.micronaut.annotation.processing.visitor.JavaParameterElement
newParameterElement
(@NonNull MethodElement methodElement, @NonNull VariableElement variableElement) Creates a new parameter element for the given args.boolean
overrides
(MethodElement overridden) Checks if this method element overrides another.withAnnotationMetadata
(AnnotationMetadata annotationMetadata) Copies this element and overrides its annotations.withNewOwningType
(ClassElement owningType) Returns a new method with a new owning type.withParameters
(ParameterElement... parameters) Takes this method element and transforms into a new method element with the given parameters.Methods inherited from class io.micronaut.annotation.processing.visitor.AbstractJavaElement
equals, getDocumentation, getModifiers, getName, hashCode, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, makeCopy, newClassElement, newClassElement, resolveTypeArguments, resolveTypeArguments, toString
Methods inherited from class io.micronaut.inject.ast.annotation.AbstractAnnotationElement
annotate, annotate, annotate, annotate, annotate, getElementAnnotationMetadata, getElementAnnotationMetadataFactory, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotype
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
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.inject.ast.Element
annotate, annotate, annotate, annotate, annotate, getDescription, getDocumentation, getName, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotype
Methods inherited from interface io.micronaut.inject.ast.MemberElement
getModifiers, isAccessible, isAccessible, isReflectionRequired, isReflectionRequired
Methods inherited from interface io.micronaut.inject.ast.MethodElement
addAssociatedBean, getDescription, hasParameters, withNewParameters
-
Field Details
-
owningType
-
executableElement
-
-
Constructor Details
-
JavaMethodElement
public JavaMethodElement(JavaClassElement owningType, JavaNativeElement.Method nativeElement, ElementAnnotationMetadataFactory annotationMetadataFactory, JavaVisitorContext visitorContext) - Parameters:
owningType
- The declaring classnativeElement
- The native elementannotationMetadataFactory
- The annotation metadata factoryvisitorContext
- The visitor context
-
-
Method Details
-
getAnnotationMetadataToWrite
Description copied from class:AbstractAnnotationElement
Get annotation metadata to add or remove annotations.- Overrides:
getAnnotationMetadataToWrite
in classAbstractAnnotationElement
- Returns:
- The annotation metadata to write
-
getMethodAnnotationMetadata
Description copied from interface:MethodElement
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.- Specified by:
getMethodAnnotationMetadata
in interfaceMethodElement
- Returns:
- The method annotation metadata
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProvider
Supplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA
.- Specified by:
getAnnotationMetadata
in interfaceAnnotationMetadataProvider
- Overrides:
getAnnotationMetadata
in classAbstractAnnotationElement
- Returns:
- The
AnnotationMetadata
-
getNativeType
Description copied from interface:Element
Returns the native underlying type. This API is extended by all of the inject language implementations. The object returned by this method will be the language native type the information is being retrieved from.- Specified by:
getNativeType
in interfaceElement
- Overrides:
getNativeType
in classAbstractJavaElement
- Returns:
- The native type
-
copyThis
- Specified by:
copyThis
in classAbstractJavaElement
- Returns:
- copy of this element
-
copyValues
- Overrides:
copyValues
in classAbstractJavaElement
- Parameters:
element
- the values to be copied to
-
withAnnotationMetadata
Description copied from interface:Element
Copies this element and overrides its annotations.- Specified by:
withAnnotationMetadata
in interfaceElement
- Specified by:
withAnnotationMetadata
in interfaceMemberElement
- Specified by:
withAnnotationMetadata
in interfaceMethodElement
- Overrides:
withAnnotationMetadata
in classAbstractJavaElement
- Parameters:
annotationMetadata
- The annotation metadata- Returns:
- A new element
-
withParameters
Description copied from interface:MethodElement
Takes this method element and transforms into a new method element with the given parameters.- Specified by:
withParameters
in interfaceMethodElement
- Parameters:
parameters
- The new parameters- Returns:
- A new method element
-
getReceiverType
Description copied from interface:MethodElement
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.
- Specified by:
getReceiverType
in interfaceMethodElement
- Returns:
- The receiver type for the method if one exists.
-
getThrownTypes
Description copied from interface:MethodElement
Returns the types declared in thethrows
declaration of a method.- Specified by:
getThrownTypes
in interfaceMethodElement
- Returns:
- The
throws
types, if any. Nevernull
.
-
isDefault
public boolean isDefault()Description copied from interface:MethodElement
Is the method a default method on an interfaces.- Specified by:
isDefault
in interfaceMethodElement
- Returns:
- True if it is.
-
isVarArgs
public boolean isVarArgs()Description copied from interface:MethodElement
If method has varargs parameter.- Specified by:
isVarArgs
in interfaceMethodElement
- Returns:
- True if it does
-
overrides
Description copied from interface:MethodElement
Checks if this method element overrides another.- Specified by:
overrides
in interfaceMethodElement
- Parameters:
overridden
- Possible overridden method- Returns:
- true if this overrides passed method element
-
hides
Description copied from interface:MemberElement
Checks if this member element hides another.- Specified by:
hides
in interfaceMemberElement
- Specified by:
hides
in interfaceMethodElement
- Parameters:
hidden
- The possibly hidden element- Returns:
- true if this member element hides passed field element
-
getGenericReturnType
Description copied from interface:MethodElement
The generic return type of the method.- Specified by:
getGenericReturnType
in interfaceMethodElement
- Returns:
- The return type of the method
-
getReturnType
- Specified by:
getReturnType
in interfaceMethodElement
- Returns:
- The return type of the method
-
getDeclaredTypeVariables
- Specified by:
getDeclaredTypeVariables
in interfaceMethodElement
- Returns:
- The type arguments declared on this method.
-
getTypeArguments
Description copied from interface:MethodElement
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.- Specified by:
getTypeArguments
in interfaceMethodElement
- Returns:
- The type arguments for this method element
-
getDeclaredTypeArguments
Description copied from interface:MethodElement
The declared type arguments for this method element.- Specified by:
getDeclaredTypeArguments
in interfaceMethodElement
- Returns:
- The declared type arguments for this method element
-
isSuspend
public boolean isSuspend()Description copied from interface:MethodElement
Is the method a Kotlin suspend function.- Specified by:
isSuspend
in interfaceMethodElement
- Returns:
- True if it is.
-
getParameters
- Specified by:
getParameters
in interfaceMethodElement
- Returns:
- The method parameters
-
withNewOwningType
Description copied from interface:MethodElement
Returns a new method with a new owning type.- Specified by:
withNewOwningType
in interfaceMethodElement
- Parameters:
owningType
- The owning type.- Returns:
- A new method element
-
getSuspendParameters
Description copied from interface:MethodElement
IfMethodElement.isSuspend()
returns true this method exposes the continuation parameter in addition to the other parameters of the method.- Specified by:
getSuspendParameters
in interfaceMethodElement
- Returns:
- The suspend parameters
-
newParameterElement
@NonNull protected @NonNull io.micronaut.annotation.processing.visitor.JavaParameterElement newParameterElement(@NonNull @NonNull MethodElement methodElement, @NonNull @NonNull VariableElement variableElement) Creates a new parameter element for the given args.- Parameters:
methodElement
- The method elementvariableElement
- The variable element- Returns:
- The parameter element
-
getDeclaringType
- Specified by:
getDeclaringType
in interfaceMemberElement
- Returns:
- The declaring type of the element.
-
getOwningType
Description copied from interface:MemberElement
The owing type is the type that owns this element. This can differ fromMemberElement.getDeclaringType()
in the case of inheritance since this method will return the subclass that owners the inherited member, whilstMemberElement.getDeclaringType()
will return the super class that declares the type.- Specified by:
getOwningType
in interfaceMemberElement
- Returns:
- The owning type.
-