Package io.micronaut.ast.groovy.visitor
Class GroovyFieldElement
java.lang.Object
io.micronaut.inject.ast.annotation.AbstractAnnotationElement
io.micronaut.ast.groovy.visitor.AbstractGroovyElement
io.micronaut.ast.groovy.visitor.GroovyFieldElement
- All Implemented Interfaces:
AnnotatedElement
,AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,Described
,Named
,MutableAnnotationMetadataDelegate<Element>
,Element
,FieldElement
,MemberElement
,TypedElement
A field element returning data from a
FieldNode
. The
variable could be a field or property node.- Since:
- 1.0
- Author:
- James Kleeh
-
Field Summary
Fields inherited from class io.micronaut.ast.groovy.visitor.AbstractGroovyElement
compilationUnit, sourceUnit, 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull AbstractGroovyElement
Constructs this element by invoking the constructor.int
If the type is an array, the number of dimensions.Returns the value of this variable if this is afinal
field initialized to a compile-time constant.Obtain the generic type with the associated annotation metadata for the field.Returns the generic type of the element.getName()
The owing type is the type that owns this element.getType()
boolean
boolean
isArray()
Is the type an array.boolean
isFinal()
boolean
boolean
Whether the type is primitive.boolean
boolean
boolean
isPublic()
boolean
isStatic()
toString()
withAnnotationMetadata
(AnnotationMetadata annotationMetadata) Copies this element and overrides its annotations.Methods inherited from class io.micronaut.ast.groovy.visitor.AbstractGroovyElement
copy, copyValues, equals, getDocumentation, getNativeType, hashCode, newClassElement, newClassElement, newClassElement, resolveClassTypeArguments, resolveMethodTypeArguments, resolveModifiers, resolveModifiers, resolveModifiers, resolveTypeArgumentsToObject
Methods inherited from class io.micronaut.inject.ast.annotation.AbstractAnnotationElement
annotate, annotate, annotate, annotate, annotate, getAnnotationMetadata, getAnnotationMetadataToWrite, 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.core.annotation.AnnotationMetadataProvider
getAnnotationMetadata
Methods inherited from interface io.micronaut.inject.ast.Element
annotate, annotate, annotate, annotate, annotate, getDescription, getDocumentation, getNativeType, getSimpleName, isSynthetic, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotype
Methods inherited from interface io.micronaut.inject.ast.FieldElement
getDescription, hides
Methods inherited from interface io.micronaut.inject.ast.MemberElement
isAccessible, isAccessible, isAccessible, isReflectionRequired, isReflectionRequired
Methods inherited from interface io.micronaut.inject.ast.TypedElement
isVoid
-
Method Details
-
copyConstructor
Description copied from class:AbstractGroovyElement
Constructs this element by invoking the constructor.- Specified by:
copyConstructor
in classAbstractGroovyElement
- Returns:
- the copy
-
withAnnotationMetadata
Description copied from interface:Element
Copies this element and overrides its annotations.- Specified by:
withAnnotationMetadata
in interfaceElement
- Specified by:
withAnnotationMetadata
in interfaceFieldElement
- Specified by:
withAnnotationMetadata
in interfaceMemberElement
- Overrides:
withAnnotationMetadata
in classAbstractGroovyElement
- Parameters:
annotationMetadata
- The annotation metadata- Returns:
- A new 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.
-
getModifiers
- Specified by:
getModifiers
in interfaceElement
- Specified by:
getModifiers
in interfaceMemberElement
- Returns:
- The
ElementModifier
types for this class element
-
toString
-
getGenericField
Description copied from interface:FieldElement
Obtain the generic type with the associated annotation metadata for the field.- Specified by:
getGenericField
in interfaceFieldElement
- Returns:
- The generic field
-
isPrimitive
public boolean isPrimitive()Description copied from interface:TypedElement
Whether the type is primitive.- Specified by:
isPrimitive
in interfaceTypedElement
- Returns:
- True if it is
-
isArray
public boolean isArray()Description copied from interface:TypedElement
Is the type an array.- Specified by:
isArray
in interfaceTypedElement
- Returns:
- True if it is.
-
getArrayDimensions
public int getArrayDimensions()Description copied from interface:TypedElement
If the type is an array, the number of dimensions. String[] should return 1, String[][] should return 2- Specified by:
getArrayDimensions
in interfaceTypedElement
- Returns:
- The number of dimensions
-
getName
-
isAbstract
public boolean isAbstract()- Specified by:
isAbstract
in interfaceElement
- Returns:
- True if the element is abstract.
-
isStatic
public boolean isStatic() -
isPublic
public boolean isPublic() -
isPrivate
public boolean isPrivate() -
isFinal
public boolean isFinal() -
isProtected
public boolean isProtected()- Specified by:
isProtected
in interfaceElement
- Returns:
- True if the element is protected.
-
isPackagePrivate
public boolean isPackagePrivate()- Specified by:
isPackagePrivate
in interfaceElement
- Overrides:
isPackagePrivate
in classAbstractGroovyElement
- Returns:
- True if the element is package private.
-
getConstantValue
Description copied from interface:FieldElement
Returns the value of this variable if this is afinal
field initialized to a compile-time constant. Returnsnull
otherwise. The value will be of a primitive type or aString
. If the value is of a primitive type, it is wrapped in the appropriate wrapper class (such asInteger
).Note that not all
final
fields will have constant values. In particular,enum
constants are not considered to be compile-time constants. To have a constant value, a field's type must be either a primitive type orString
.- Specified by:
getConstantValue
in interfaceFieldElement
- Returns:
- the value of this variable if this is a
final
field initialized to a compile-time constant, ornull
otherwise
-
getType
- Specified by:
getType
in interfaceTypedElement
- Returns:
- The type of the element
-
getGenericType
Description copied from interface:TypedElement
Returns 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:
getGenericType
in interfaceTypedElement
- Returns:
- The generic type
-
getDeclaringType
- Specified by:
getDeclaringType
in interfaceMemberElement
- Returns:
- The declaring type of the element.
-