Class PythonParameterElement
java.lang.Object
io.micronaut.inject.ast.annotation.AbstractAnnotationElement
io.micronaut.python.processing.element.PythonParameterElement
- All Implemented Interfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Named, MutableAnnotationMetadataDelegate<Element>, Element, ParameterElement, TypedElement
public final class PythonParameterElement
extends AbstractAnnotationElement
implements ParameterElement
A parameter element representing a Python function parameter.
This class wraps parameter information from a Python function argument, providing type resolution and metadata for Micronaut's parameter processing.
- Since:
- 5.2.0
- Author:
- Micronaut Team
-
Field Summary
Fields inherited from class AbstractAnnotationElement
elementAnnotationMetadataFactory, presetAnnotationMetadataFields inherited from interface AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface AnnotationSource
EMPTYFields inherited from interface Element
EMPTY_ELEMENT_ARRAYFields inherited from interface MutableAnnotationMetadataDelegate
EMPTYFields inherited from interface ParameterElement
ZERO_PARAMETER_ELEMENTS -
Constructor Summary
ConstructorsConstructorDescriptionPythonParameterElement(ArgumentDef argumentDef, PythonProcessingEnvironment environment, PythonMethodElement methodElement, ElementAnnotationMetadataFactory metadataFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected io.micronaut.python.processing.element.AbstractPythonElementcopyThis()protected voidcopyValues(io.micronaut.python.processing.element.AbstractPythonElement element) booleanprotected MutableAnnotationMetadataDelegate<?> Annotations added by a visitor go to the metadata of the Python parameter itself, which is cached for the parameter: every view of the parameter (each query of the enclosed methods answers a new copy) sees them, the inherited metadata being a read-only view over it.getDocumentation(boolean parseContent) protected ElementAnnotationMetadataThe annotation metadata read from this parameter: the annotations declared on the Python parameter, seen through those inherited from the overridden Java parameter, as for the parameters of an overriding Java method (the inherited ones are visible tohasAnnotationbut not tohasDeclaredAnnotation).Returns the generic type of the element.Return method associated with this parameter.Python has no access modifiers, so the modifiers are derived from the visibility, static, abstract and final predicates of the element: an element is public unless its name marks it private, which keeps the modifier set consistent withElement.isPublic(),Element.isStatic(),Element.isAbstract()andElement.isFinal()for the callers that filter on modifiers, such asElementQuery.modifiers(...)andBeanElementBuilder.produceBeans(...).getName()Returns the native underlying type.getType()booleanWhether the parameter declares a default value in the source language, and is therefore optional at the call site.inthashCode()booleanbooleanisPublic()booleanprotected final io.micronaut.python.processing.element.AbstractPythonElementmakeCopy()withAnnotationMetadata(AnnotationMetadata annotationMetadata) Copies this element and overrides its annotations.withInheritedAnnotationMetadata(AnnotationMetadata annotationMetadata) Returns a copy of this parameter that inherits the given annotation metadata, the annotations of the corresponding parameter of a method the Python method overrides (the constraints of a Java interface method).Returns a copy of this parameter that reports the given type, the type of the corresponding parameter of the Java method the Python method overrides, in place of the one resolved from the Python hint.Methods inherited from class AbstractAnnotationElement
annotate, annotate, annotate, annotate, annotate, getAnnotationMetadata, getElementAnnotationMetadataFactory, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotypeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullableMethods inherited from interface AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods inherited from interface 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, hasEvaluatedExpressions, 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 AnnotationMetadataProvider
getAnnotationMetadataMethods inherited from interface Element
annotate, annotate, annotate, annotate, annotate, getDescription, getDocumentation, getModifiers, getName, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotypeMethods inherited from interface ParameterElement
getDescriptionMethods inherited from interface TypedElement
getArrayDimensions, isArray, isPrimitive, isVoid
-
Constructor Details
-
PythonParameterElement
public PythonParameterElement(ArgumentDef argumentDef, PythonProcessingEnvironment environment, PythonMethodElement methodElement, ElementAnnotationMetadataFactory metadataFactory)
-
-
Method Details
-
getElementAnnotationMetadata
The annotation metadata read from this parameter: the annotations declared on the Python parameter, seen through those inherited from the overridden Java parameter, as for the parameters of an overriding Java method (the inherited ones are visible tohasAnnotationbut not tohasDeclaredAnnotation).- Overrides:
getElementAnnotationMetadatain classAbstractAnnotationElement- Returns:
- The element's annotation metadata
-
getAnnotationMetadataToWrite
Annotations added by a visitor go to the metadata of the Python parameter itself, which is cached for the parameter: every view of the parameter (each query of the enclosed methods answers a new copy) sees them, the inherited metadata being a read-only view over it.- Overrides:
getAnnotationMetadataToWritein classAbstractAnnotationElement- Returns:
- The annotation metadata to write
-
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- Returns:
- The native type
-
hasDefault
public boolean hasDefault()Description copied from interface:ParameterElementWhether the parameter declares a default value in the source language, and is therefore optional at the call site.This reports only that a default exists. How the value is obtained is language specific and is deliberately not part of this contract:
- some languages evaluate the default in the caller, in which case the language
module may contribute an
io.micronaut.inject.writer.ParameterDefaultValueProviderto supply it; - others evaluate it in the callee and require a dedicated calling convention,
as
KotlinParameterElementdoes.
- Specified by:
hasDefaultin interfaceParameterElement- Returns:
- True if the parameter has a default value
- some languages evaluate the default in the caller, in which case the language
module may contribute an
-
getType
- Specified by:
getTypein interfaceParameterElement- Specified by:
getTypein interfaceTypedElement- Returns:
- The type of the parameter
-
getGenericType
Description copied from interface:TypedElementReturns the generic type of the element. This differs fromTypedElement.getType()as it returns the actual type without erasure. WhilstTypedElement.getType()is often needed to produce the correct byte code when generating code via ASM, thegetGenericType()method is more useful for documentation and other types of code generation.- Specified by:
getGenericTypein interfaceTypedElement- Returns:
- The generic type
-
isVariadic
public boolean isVariadic()- Returns:
- Whether this is the variadic (
*args) parameter of its function
-
getMethodElement
Description copied from interface:ParameterElementReturn method associated with this parameter.- Specified by:
getMethodElementin interfaceParameterElement- Returns:
- The method element
-
getDocumentation
- Specified by:
getDocumentationin interfaceElement- Parameters:
parseContent- True if the content should be parsed to extract documentation- Returns:
- The documentation, if any.
-
withInheritedType
Returns a copy of this parameter that reports the given type, the type of the corresponding parameter of the Java method the Python method overrides, in place of the one resolved from the Python hint. The copy remains a parameter of the Python method: it keeps the Python name, the method element and the annotation metadata.- Parameters:
type- The type of the overridden Java parameter- Returns:
- The copy
-
withInheritedAnnotationMetadata
public PythonParameterElement withInheritedAnnotationMetadata(AnnotationMetadata annotationMetadata) Returns a copy of this parameter that inherits the given annotation metadata, the annotations of the corresponding parameter of a method the Python method overrides (the constraints of a Java interface method). They are read through this parameter as inherited annotations, in addition to any inherited earlier, while annotations added to the copy go to the parameter's own metadata, so a visitor that annotates the parameter while inheriting annotations itself (the validation visitor) works on it.- Parameters:
annotationMetadata- The annotation metadata of the overridden parameter- Returns:
- The copy
-
copyThis
protected io.micronaut.python.processing.element.AbstractPythonElement copyThis()- Returns:
- copy of this element
-
withAnnotationMetadata
Description copied from interface:ElementCopies this element and overrides its annotations.- Specified by:
withAnnotationMetadatain interfaceElement- Specified by:
withAnnotationMetadatain interfaceParameterElement- Parameters:
annotationMetadata- The annotation metadata- Returns:
- A new element
-
copyValues
protected void copyValues(io.micronaut.python.processing.element.AbstractPythonElement element) - Parameters:
element- the values to be copied to
-
makeCopy
protected final io.micronaut.python.processing.element.AbstractPythonElement makeCopy() -
getName
-
isProtected
public boolean isProtected()- Specified by:
isProtectedin interfaceElement- Returns:
- True if the element is protected.
-
isPublic
-
getModifiers
Python has no access modifiers, so the modifiers are derived from the visibility, static, abstract and final predicates of the element: an element is public unless its name marks it private, which keeps the modifier set consistent withElement.isPublic(),Element.isStatic(),Element.isAbstract()andElement.isFinal()for the callers that filter on modifiers, such asElementQuery.modifiers(...)andBeanElementBuilder.produceBeans(...).- Specified by:
getModifiersin interfaceElement- Returns:
- The modifiers
-
equals
-
hashCode
-