Class PythonPropertyElement
java.lang.Object
io.micronaut.inject.ast.annotation.AbstractAnnotationElement
io.micronaut.python.processing.visitor.PythonPropertyElement
- All Implemented Interfaces:
ElementProvider, AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Named, MutableAnnotationMetadataDelegate<Element>, Element, MemberElement, PropertyElement, TypedElement
public final class PythonPropertyElement
extends AbstractAnnotationElement
implements PropertyElement, ElementProvider
A property element representing a Python property (either a @property decorated method or a regular attribute).
This class implements the PropertyElement interface to provide property support for Python classes.
Properties can be created from:
- @property decorated methods with optional @property.setter decorators
- Regular Python attributes (fields)
- Since:
- 5.2.0
- Author:
- Micronaut Team
-
Nested Class Summary
Nested classes/interfaces inherited from interface PropertyElement
PropertyElement.AccessKind -
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
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionPythonPropertyElement(PropertyDef propertyDef, PythonProcessingEnvironment environment, ClassElement declaringType, ClassElement owningType, ElementAnnotationMetadataFactory metadataFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected io.micronaut.python.processing.visitor.AbstractPythonElementcopyThis()protected voidcopyValues(io.micronaut.python.processing.visitor.AbstractPythonElement element) element()booleanSupplies the metadata.Get annotation metadata to add or remove annotations.getDocumentation(boolean parseContent) Returns the generic type of the element.getName()Returns the native underlying type.The owning type is the type that owns this element.Optional<? extends MemberElement> getType()Optional<? extends MemberElement> inthashCode()booleanbooleanisPublic()booleanReturn true only if the property has a getter but no setter.booleanReturn true only if the property doesn't support modifying the value.protected final io.micronaut.python.processing.visitor.AbstractPythonElementmakeCopy()booleanoverrides(PropertyElement overridden) Does this property override the given property.withAnnotationMetadata(AnnotationMetadata annotationMetadata) Copies this element and overrides its annotations.Methods inherited from class AbstractAnnotationElement
annotate, annotate, annotate, annotate, annotate, 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 Element
annotate, annotate, annotate, annotate, annotate, getDescription, getDescription, getDocumentation, getName, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotypeMethods inherited from interface MemberElement
getModifiers, hides, isAccessible, isAccessible, isAccessible, isReflectionRequired, isReflectionRequiredMethods inherited from interface PropertyElement
getField, isExcludedMethods inherited from interface TypedElement
getArrayDimensions, isArray, isPrimitive, isVoid
-
Constructor Details
-
PythonPropertyElement
public PythonPropertyElement(PropertyDef propertyDef, PythonProcessingEnvironment environment, ClassElement declaringType, ClassElement owningType, ElementAnnotationMetadataFactory metadataFactory)
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getElementAnnotationMetadata
- Overrides:
getElementAnnotationMetadatain classAbstractAnnotationElement- Returns:
- The element's annotation metadata
-
getAnnotationMetadataToWrite
Description copied from class:AbstractAnnotationElementGet annotation metadata to add or remove annotations.- Overrides:
getAnnotationMetadataToWritein classAbstractAnnotationElement- Returns:
- The annotation metadata to write
-
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- Returns:
- The native type
-
getType
- Specified by:
getTypein interfacePropertyElement- Specified by:
getTypein interfaceTypedElement- Returns:
- The type of the property
-
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
-
getReadMethod
- Specified by:
getReadMethodin interfacePropertyElement- Returns:
- The method to read the property
-
getWriteMethod
- Specified by:
getWriteMethodin interfacePropertyElement- Returns:
- The method to write the property
-
getReadAccessKind
- Specified by:
getReadAccessKindin interfacePropertyElement- Returns:
- The read access kind of the property
-
getWriteAccessKind
- Specified by:
getWriteAccessKindin interfacePropertyElement- Returns:
- The write access kind of the property
-
getDeclaringType
- Specified by:
getDeclaringTypein interfaceMemberElement- Returns:
- The declaring type of the element.
-
getOwningType
Description copied from interface:MemberElementThe owning 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.
-
element
- Specified by:
elementin interfaceElementProvider- Returns:
- The native element.
-
isReadOnly
public boolean isReadOnly()Description copied from interface:PropertyElementReturn true only if the property has a getter but no setter.- Specified by:
isReadOnlyin interfacePropertyElement- Returns:
- True if the property is read only.
-
isWriteOnly
public boolean isWriteOnly()Description copied from interface:PropertyElementReturn true only if the property doesn't support modifying the value.- Specified by:
isWriteOnlyin interfacePropertyElement- Returns:
- True if the property is writing only.
-
getReadMember
- Specified by:
getReadMemberin interfacePropertyElement- Returns:
- The member to read the property
-
getWriteMember
- Specified by:
getWriteMemberin interfacePropertyElement- Returns:
- The member to write the property
-
getReadType
- Specified by:
getReadTypein interfacePropertyElement- Returns:
- The read type.
-
getWriteType
- Specified by:
getWriteTypein interfacePropertyElement- Returns:
- The write type.
-
getReadTypeAnnotationMetadata
- Specified by:
getReadTypeAnnotationMetadatain interfacePropertyElement- Returns:
- The read type annotation metadata.
-
getWriteTypeAnnotationMetadata
- Specified by:
getWriteTypeAnnotationMetadatain interfacePropertyElement- Returns:
- The write type annotation metadata.
-
overrides
Description copied from interface:PropertyElementDoes this property override the given property. Supported only with languages that have native properties.- Specified by:
overridesin interfacePropertyElement- Parameters:
overridden- The overridden method.- Returns:
- True this property overrides the given property.
-
getDocumentation
- Specified by:
getDocumentationin interfaceElement- Specified by:
getDocumentationin interfacePropertyElement- Parameters:
parseContent- True if the content should be parsed to extract documentation- Returns:
- The documentation, if any.
-
copyThis
protected io.micronaut.python.processing.visitor.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 interfaceMemberElement- Parameters:
annotationMetadata- The annotation metadata- Returns:
- A new element
-
copyValues
protected void copyValues(io.micronaut.python.processing.visitor.AbstractPythonElement element) - Parameters:
element- the values to be copied to
-
makeCopy
protected final io.micronaut.python.processing.visitor.AbstractPythonElement makeCopy() -
getName
-
isProtected
public boolean isProtected()- Specified by:
isProtectedin interfaceElement- Returns:
- True if the element is protected.
-
isPublic
-