@Internal public class GroovyClassElement extends AbstractGroovyElement implements ArrayableClassElement
ClassNode.| Modifier and Type | Field and Description |
|---|---|
protected org.codehaus.groovy.ast.ClassNode |
classNode |
compilationUnit, sourceUnit, visitorContextZERO_CLASS_ELEMENTSEMPTY_ELEMENT_ARRAYCLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBEREMPTY| Constructor and Description |
|---|
GroovyClassElement(GroovyVisitorContext visitorContext,
org.codehaus.groovy.ast.ClassNode classNode,
AnnotationMetadata annotationMetadata) |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Map<String,ClassElement>> |
getAllTypeArguments()
Builds a map of all the type parameters for a class, its super classes and interfaces.
|
int |
getArrayDimensions()
If the type is an array, the number of dimensions.
|
List<PropertyElement> |
getBeanProperties()
Returns the bean properties (getters and setters) for this class element.
|
List<? extends ClassElement> |
getBoundGenericTypes()
The list of type arguments bound to this type, or an empty list if there are no type arguments or this is a raw
type.
|
List<? extends GenericPlaceholderElement> |
getDeclaredGenericPlaceholders()
The type arguments declared on the raw class.
|
Optional<MethodElement> |
getDefaultConstructor()
Find and return a single default constructor.
|
<T extends Element> |
getEnclosedElements(ElementQuery<T> query)
Return the elements that match the given query.
|
Optional<ClassElement> |
getEnclosingType()
Returns the enclosing type if
ClassElement.isInner() return true. |
Map<String,Map<String,org.codehaus.groovy.ast.ClassNode>> |
getGenericTypeInfo()
Builds and returns the generic type information.
|
Collection<ClassElement> |
getInterfaces() |
Set<ElementModifier> |
getModifiers() |
String |
getName() |
Object |
getNativeType()
Returns the native underlying type.
|
PackageElement |
getPackage()
The package name.
|
String |
getPackageName()
The package name.
|
Optional<MethodElement> |
getPrimaryConstructor()
Find and return a single primary constructor.
|
String |
getSimpleName()
The simple name without the package name.
|
Optional<ClassElement> |
getSuperType()
Returns the super type of this element or empty if the element has no super type.
|
Map<String,ClassElement> |
getTypeArguments() |
Map<String,ClassElement> |
getTypeArguments(String type)
Get the type arguments for the given type name.
|
boolean |
isAbstract() |
boolean |
isArray()
Is the type an array.
|
boolean |
isAssignable(ClassElement type)
Tests whether one type is assignable to another.
|
boolean |
isAssignable(String type)
Tests whether one type is assignable to another.
|
boolean |
isFinal() |
boolean |
isInner()
Is this type an inner class.
|
boolean |
isInterface() |
boolean |
isPrimitive()
Whether the type is primitive.
|
boolean |
isPrivate() |
boolean |
isProtected() |
boolean |
isPublic() |
boolean |
isStatic() |
boolean |
isTypeVariable()
In this case of calling
ClassElement.getTypeArguments() a returned ClassElement may represent a type variable
in which case this method will return true. |
protected ClassElement |
toClassElement(org.codehaus.groovy.ast.ClassNode classNode) |
String |
toString() |
ClassElement |
withArrayDimensions(int arrayDimensions)
Convert the class element to an element for the same type, but with the given number of array dimensions.
|
ClassElement |
withBoundGenericTypes(List<? extends ClassElement> typeArguments)
Get a
ClassElement instance corresponding to this type, but with the given type arguments. |
alignNewGenericsInfo, annotate, annotate, equals, getAnnotationMetadata, getGenericElement, hashCode, isPackagePrivate, removeAnnotation, removeAnnotationIf, removeStereotype, resolveAnnotationMetadata, resolveModifiers, resolveModifiers, resolveModifiersclone, finalize, getClass, notify, notifyAll, wait, wait, waitfromArray, toArrayaddAssociatedBean, foldBoundGenericTypes, getCanonicalName, getEnclosedElement, getFields, getFields, getFirstTypeArgument, getRawClassElement, getType, getTypeArguments, isAssignable, isEnum, isGenericPlaceholder, isIterable, isOptional, isProxy, isRecord, isWildcard, of, of, of, of, of, ofgetGenericTypeannotate, annotate, annotate, annotate, annotate, getDescription, getDescription, getDocumentation, isPackagePrivate, removeAnnotation, removeAnnotation, removeAnnotationIf, removeStereotype, removeStereotypebooleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, 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, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, 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, synthesizeDeclaredAnnotationsByTypegetAnnotationValuesByName, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresentisDeclaredNonNull, isDeclaredNullable, isNonNull, isNullablegetAnnotationMetadatapublic GroovyClassElement(GroovyVisitorContext visitorContext, org.codehaus.groovy.ast.ClassNode classNode, AnnotationMetadata annotationMetadata)
visitorContext - The visitor contextclassNode - The ClassNodeannotationMetadata - The annotation metadatapublic boolean isTypeVariable()
ClassElementClassElement.getTypeArguments() a returned ClassElement may represent a type variable
in which case this method will return true.isTypeVariable in interface ClassElementpublic <T extends Element> List<T> getEnclosedElements(@NonNull ElementQuery<T> query)
ClassElementgetEnclosedElements in interface ClassElementT - The element typequery - The query to use.public Set<ElementModifier> getModifiers()
getModifiers in interface ElementElementModifier types for this class elementpublic boolean isInner()
ClassElementisInner in interface ClassElementpublic Optional<ClassElement> getEnclosingType()
ClassElementClassElement.isInner() return true.getEnclosingType in interface ClassElementpublic boolean isInterface()
isInterface in interface ClassElementpublic boolean isPrimitive()
TypedElementisPrimitive in interface TypedElementpublic Collection<ClassElement> getInterfaces()
getInterfaces in interface ClassElementpublic Optional<ClassElement> getSuperType()
ClassElementgetSuperType in interface ClassElement@NonNull public Optional<MethodElement> getPrimaryConstructor()
ClassElementCreator or Inject.getPrimaryConstructor in interface ClassElement@NonNull public Optional<MethodElement> getDefaultConstructor()
ClassElementgetDefaultConstructor in interface ClassElementpublic Map<String,Map<String,org.codehaus.groovy.ast.ClassNode>> getGenericTypeInfo()
@NonNull public Map<String,ClassElement> getTypeArguments(@NonNull String type)
ClassElementgetTypeArguments in interface ClassElementtype - The type to retrieve type arguments for@NonNull public Map<String,Map<String,ClassElement>> getAllTypeArguments()
ClassElementgetAllTypeArguments in interface ClassElement@NonNull public Map<String,ClassElement> getTypeArguments()
getTypeArguments in interface ClassElementpublic List<PropertyElement> getBeanProperties()
ClassElementgetBeanProperties in interface ClassElementpublic boolean isArray()
TypedElementisArray in interface TypedElementpublic ClassElement withArrayDimensions(int arrayDimensions)
ArrayableClassElementwithArrayDimensions in interface ArrayableClassElementarrayDimensions - The number of array dimensions of the new class elementpublic int getArrayDimensions()
TypedElementgetArrayDimensions in interface TypedElementpublic String getName()
public String getSimpleName()
ClassElementgetSimpleName in interface ClassElementgetSimpleName in interface Elementpublic String getPackageName()
ClassElementgetPackageName in interface ClassElementpublic PackageElement getPackage()
ClassElementgetPackage in interface ClassElementpublic boolean isAbstract()
isAbstract in interface Elementpublic boolean isStatic()
public boolean isPublic()
public boolean isPrivate()
public boolean isFinal()
public boolean isProtected()
isProtected in interface Elementpublic Object getNativeType()
ElementgetNativeType in interface Elementpublic boolean isAssignable(String type)
ClassElementisAssignable in interface ClassElementtype - The type to checktrue if and only if this type is assignable to the secondpublic boolean isAssignable(ClassElement type)
ClassElementisAssignable in interface ClassElementtype - The type to checktrue if and only if this type is assignable to the second@NonNull public List<? extends ClassElement> getBoundGenericTypes()
ClassElement
Note that for compatibility reasons, this method is inconsistent with ClassElement.getTypeArguments(). In particular,
this method reflects the declaration type: If there is a class Test<T> { T field; }, this method
will return T as the field type, even if the field type was obtained through a Test<String>.
getBoundGenericTypes in interface ClassElementClassElement.getDeclaredGenericPlaceholders(). Must be empty or
of the same length as ClassElement.getDeclaredGenericPlaceholders().@NonNull public List<? extends GenericPlaceholderElement> getDeclaredGenericPlaceholders()
ClassElementbound type arguments.
This method will resolve the generic placeholders defined of the declaring class, if any.
For example List<String> will result a single placeholder called E of type Object.
getDeclaredGenericPlaceholders in interface ClassElementprotected final ClassElement toClassElement(org.codehaus.groovy.ast.ClassNode classNode)
@NonNull public ClassElement withBoundGenericTypes(@NonNull List<? extends ClassElement> typeArguments)
ClassElementClassElement instance corresponding to this type, but with the given type arguments. This is best
effort – implementations may only support ClassElements that come from the same visitor context, and
other ClassElements only to a limited degree.withBoundGenericTypes in interface ClassElementtypeArguments - The new type arguments.ClassElement of the same raw class with the new type arguments.