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
FieldsModifier and TypeFieldDescriptionprotected final ExecutableElementprotected final JavaClassElementFields inherited from class io.micronaut.annotation.processing.visitor.AbstractJavaElement
visitorContextFields inherited from class io.micronaut.inject.ast.annotation.AbstractAnnotationElement
elementAnnotationMetadataFactory, presetAnnotationMetadataFields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTYFields inherited from interface io.micronaut.inject.ast.Element
EMPTY_ELEMENT_ARRAYFields inherited from interface io.micronaut.inject.ast.annotation.MutableAnnotationMetadataDelegate
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionJavaMethodElement(JavaClassElement owningType, JavaNativeElement.Method nativeElement, ElementAnnotationMetadataFactory annotationMetadataFactory, JavaVisitorContext visitorContext) -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractJavaElementcopyThis()protected voidcopyValues(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.Get overridden methods by this method.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 thethrowsdeclaration of a method.The type arguments for this method element.booleanhides(@NonNull MethodElement hiddenMethod) Checks if this member element hides another.booleanIs the method a default method on an interfaces.booleanisSubSignature(MethodElement element) Is this method a sub signature of another.booleanIs the method a Kotlin suspend function.booleanIf method has varargs parameter.protected @NonNull io.micronaut.annotation.processing.visitor.JavaParameterElementnewParameterElement(@NonNull MethodElement methodElement, @NonNull VariableElement variableElement) Creates a new parameter element for the given args.booleanoverrides(@NonNull MethodElement overridden) Checks if this method element overrides another.withAnnotationMetadata(AnnotationMetadata annotationMetadata) Copies this element and overrides its annotations.withNewOwningType(@NonNull 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, toStringMethods inherited from class io.micronaut.inject.ast.annotation.AbstractAnnotationElement
annotate, annotate, annotate, annotate, annotate, getElementAnnotationMetadata, getElementAnnotationMetadataFactory, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotypeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullableMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods 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, synthesizeDeclaredAnnotationsByTypeMethods 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, removeStereotypeMethods inherited from interface io.micronaut.inject.ast.MemberElement
getModifiers, isAccessible, isAccessible, isAccessible, isReflectionRequired, isReflectionRequiredMethods inherited from interface io.micronaut.inject.ast.MethodElement
addAssociatedBean, getDescription, hasParameters, hides, 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:AbstractAnnotationElementGet annotation metadata to add or remove annotations.- Overrides:
getAnnotationMetadataToWritein classAbstractAnnotationElement- Returns:
- The annotation metadata to write
-
getMethodAnnotationMetadata
Description copied from interface:MethodElementReturns 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:
getMethodAnnotationMetadatain interfaceMethodElement- Returns:
- The method annotation metadata
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProviderSupplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA.- Specified by:
getAnnotationMetadatain interfaceAnnotationMetadataProvider- Overrides:
getAnnotationMetadatain classAbstractAnnotationElement- Returns:
- The
AnnotationMetadata
-
getNativeType
Description copied from interface:ElementReturns the native underlying type. This API is extended by all inject language implementations. The object returned by this method will be the language native type the information is being retrieved from.- Specified by:
getNativeTypein interfaceElement- Overrides:
getNativeTypein classAbstractJavaElement- Returns:
- The native type
-
copyThis
- Specified by:
copyThisin classAbstractJavaElement- Returns:
- copy of this element
-
copyValues
- Overrides:
copyValuesin classAbstractJavaElement- Parameters:
element- the values to be copied to
-
withAnnotationMetadata
Description copied from interface:ElementCopies this element and overrides its annotations.- Specified by:
withAnnotationMetadatain interfaceElement- Specified by:
withAnnotationMetadatain interfaceMemberElement- Specified by:
withAnnotationMetadatain interfaceMethodElement- Overrides:
withAnnotationMetadatain classAbstractJavaElement- Parameters:
annotationMetadata- The annotation metadata- Returns:
- A new element
-
withParameters
Description copied from interface:MethodElementTakes this method element and transforms into a new method element with the given parameters.- Specified by:
withParametersin interfaceMethodElement- Parameters:
parameters- The new parameters- Returns:
- A new method element
-
getReceiverType
Description copied from interface:MethodElementReturns 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:
getReceiverTypein interfaceMethodElement- Returns:
- The receiver type for the method if one exists.
-
getThrownTypes
Description copied from interface:MethodElementReturns the types declared in thethrowsdeclaration of a method.- Specified by:
getThrownTypesin interfaceMethodElement- Returns:
- The
throwstypes, if any. Nevernull.
-
isDefault
public boolean isDefault()Description copied from interface:MethodElementIs the method a default method on an interfaces.- Specified by:
isDefaultin interfaceMethodElement- Returns:
- True if it is.
-
isVarArgs
public boolean isVarArgs()Description copied from interface:MethodElementIf method has varargs parameter.- Specified by:
isVarArgsin interfaceMethodElement- Returns:
- True if it does
-
overrides
Description copied from interface:MethodElementChecks if this method element overrides another.- Specified by:
overridesin interfaceMethodElement- Parameters:
overridden- Possible overridden method- Returns:
- true if this overrides passed method element
-
isSubSignature
Description copied from interface:MethodElementIs this method a sub signature of another.- Specified by:
isSubSignaturein interfaceMethodElement- Parameters:
element- The other method- Returns:
- true if a sub signature
-
hides
Description copied from interface:MethodElementChecks if this member element hides another.- Specified by:
hidesin interfaceMethodElement- Parameters:
hiddenMethod- The possibly hidden method- Returns:
- true if this member element hides passed field element
-
getGenericReturnType
Description copied from interface:MethodElementThe generic return type of the method.- Specified by:
getGenericReturnTypein interfaceMethodElement- Returns:
- The return type of the method
-
getReturnType
- Specified by:
getReturnTypein interfaceMethodElement- Returns:
- The return type of the method
-
getDeclaredTypeVariables
- Specified by:
getDeclaredTypeVariablesin interfaceMethodElement- Returns:
- The type arguments declared on this method.
-
getTypeArguments
Description copied from interface:MethodElementThe 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:
getTypeArgumentsin interfaceMethodElement- Returns:
- The type arguments for this method element
-
getDeclaredTypeArguments
Description copied from interface:MethodElementThe declared type arguments for this method element.- Specified by:
getDeclaredTypeArgumentsin interfaceMethodElement- Returns:
- The declared type arguments for this method element
-
isSuspend
public boolean isSuspend()Description copied from interface:MethodElementIs the method a Kotlin suspend function.- Specified by:
isSuspendin interfaceMethodElement- Returns:
- True if it is.
-
getParameters
- Specified by:
getParametersin interfaceMethodElement- Returns:
- The method parameters
-
withNewOwningType
Description copied from interface:MethodElementReturns a new method with a new owning type.- Specified by:
withNewOwningTypein interfaceMethodElement- Parameters:
owningType- The owning type.- Returns:
- A new method element
-
getSuspendParameters
Description copied from interface:MethodElementIfMethodElement.isSuspend()returns true this method exposes the continuation parameter in addition to the other parameters of the method.- Specified by:
getSuspendParametersin 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:
getDeclaringTypein interfaceMemberElement- Returns:
- The declaring type of the element.
-
getOwningType
Description copied from interface:MemberElementThe 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:
getOwningTypein interfaceMemberElement- Returns:
- The owning type.
-
getOverriddenMethods
Description copied from interface:MethodElementGet overridden methods by this method.- Specified by:
getOverriddenMethodsin interfaceMethodElement- Returns:
- The overridden method by this method.
-