Class JavaParserEnumDeclaration
java.lang.Object
com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserEnumDeclaration
- All Implemented Interfaces:
AssociableToAST, HasAccessSpecifier, ResolvedDeclaration, ResolvedEnumDeclaration, ResolvedReferenceTypeDeclaration, ResolvedTypeDeclaration, ResolvedTypeParametrizable, MethodResolutionCapability, MethodUsageResolutionCapability, SymbolResolutionCapability
public class JavaParserEnumDeclaration
extends AbstractTypeDeclaration
implements ResolvedEnumDeclaration, MethodResolutionCapability, MethodUsageResolutionCapability, SymbolResolutionCapability
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNeeded by ContextHelper An implicitly declared methodpublic static E valueOf(String name), which returns the enum constant ofEwith the specified name.static classNeeded by ContextHelper An implicitly declared methodpublic static E[] values(), which returns an array containing the enum constants ofE, in the same order as they appear in the body of the declaration of E. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JavaParserTypeAdapter<EnumDeclaration> private TypeSolverprivate static final Stringprivate EnumDeclarationFields inherited from interface ResolvedReferenceTypeDeclaration
breadthFirstFunc, depthFirstFunc, JAVA_IO_SERIALIZABLE, JAVA_LANG_COMPARABLE, JAVA_LANG_ENUM, JAVA_LANG_OBJECT, JAVA_LANG_RECORD -
Constructor Summary
ConstructorsConstructorDescriptionJavaParserEnumDeclaration(EnumDeclaration wrappedNode, TypeSolver typeSolver) -
Method Summary
Modifier and TypeMethodDescriptionThe access specifier of this element.booleanCan we assign instances of the type defined by this declaration to variables having the type defined by the given type?Get the ReferenceTypeDeclaration enclosing this declaration.booleanReturn a list of all fields, either declared in this declaration or inherited.getAncestors(boolean acceptIncompleteList) Resolves the types of all direct ancestors (i.e., the directly extended class and the directly implemented interfaces) and returns the list of ancestors as a list of resolved reference types.The class(es) wrapping this type.Return a list of all the methods declared in this type declaration.getName()Should return the name or return null if the name is not available.The package name of the type.The fully qualified name of the type declared.The list of type parameters defined on this element.Returns the JavaParser node associated with this JavaParserEnumDeclaration.booleanhasDirectlyAnnotation(String canonicalName) Has the type at least one annotation declared having the specified qualified name?inthashCode()Get the list of types defined inside the current type.booleanCan we assign instances of the given type to variables having the type defined by this declaration?booleanisAssignableBy(ResolvedType type) Can we assign instances of the given type to variables having the type defined by this declaration?booleanisClass()Is this the declaration of a class? Note that an Enum is not considered a Class in this case.booleanisField()Does this declaration represents a class field?booleanIs this the declaration of an interface?booleanDoes this declaration represents a method parameter?booleanisType()Does this declaration represents a type?booleanIs this the declaration of a type parameter?solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) solveMethodAsUsage(String name, List<ResolvedType> argumentTypes, Context invokationContext, List<ResolvedType> typeParameters) SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) Deprecated.toAst()If the declaration is associated to an AST node return it, otherwise it return empty.private ResolvedReferenceTypetoReferenceType(ClassOrInterfaceType classOrInterfaceType) toString()Methods inherited from class AbstractTypeDeclaration
getAllMethods, isFunctionalInterface, isRecordTypeMethods inherited from interface AssociableToAST
toAstMethods inherited from interface ResolvedDeclaration
asEnumConstant, asField, asMethod, asParameter, asTypePattern, hasName, isEnumConstant, isMethod, isTypePattern, isVariableMethods inherited from interface ResolvedEnumDeclaration
asEnum, getEnumConstant, hasEnumConstant, isEnumMethods inherited from interface ResolvedReferenceTypeDeclaration
asReferenceType, findTypeParameter, getAllAncestors, getAllAncestors, getAllMethods, getAllNonStaticFields, getAllStaticFields, getAncestors, getDeclaredAnnotation, getDeclaredAnnotations, getDeclaredFields, getField, getVisibleField, getVisibleFields, hasAnnotation, hasField, hasVisibleField, isFunctionalInterface, isInheritedAnnotation, isJavaLangEnum, isJavaLangObject, isJavaLangRecord, isReferenceTypeMethods inherited from interface ResolvedTypeDeclaration
asAnnotation, asClass, asInterface, asRecord, asType, asTypeParameter, getId, getInternalType, hasInternalType, isAnnotation, isAnonymousClass, isRecordMethods inherited from interface ResolvedTypeParametrizable
isGeneric
-
Field Details
-
VALUES
- See Also:
-
typeSolver
-
wrappedNode
-
javaParserTypeAdapter
-
-
Constructor Details
-
JavaParserEnumDeclaration
-
-
Method Details
-
toString
-
getDeclaredMethods
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all the methods declared in this type declaration.- Specified by:
getDeclaredMethodsin interfaceResolvedReferenceTypeDeclaration
-
getContext
-
getName
Description copied from interface:ResolvedDeclarationShould return the name or return null if the name is not available.- Specified by:
getNamein interfaceResolvedDeclaration
-
isField
public boolean isField()Description copied from interface:ResolvedDeclarationDoes this declaration represents a class field?- Specified by:
isFieldin interfaceResolvedDeclaration
-
isParameter
public boolean isParameter()Description copied from interface:ResolvedDeclarationDoes this declaration represents a method parameter?- Specified by:
isParameterin interfaceResolvedDeclaration
-
isType
public boolean isType()Description copied from interface:ResolvedDeclarationDoes this declaration represents a type?- Specified by:
isTypein interfaceResolvedDeclaration- Specified by:
isTypein interfaceResolvedTypeDeclaration
-
hasDirectlyAnnotation
Description copied from interface:ResolvedReferenceTypeDeclarationHas the type at least one annotation declared having the specified qualified name?- Specified by:
hasDirectlyAnnotationin interfaceResolvedReferenceTypeDeclaration
-
canBeAssignedTo
Description copied from interface:ResolvedReferenceTypeDeclarationCan we assign instances of the type defined by this declaration to variables having the type defined by the given type?- Specified by:
canBeAssignedToin interfaceResolvedReferenceTypeDeclaration
-
isClass
public boolean isClass()Description copied from interface:ResolvedTypeDeclarationIs this the declaration of a class? Note that an Enum is not considered a Class in this case.- Specified by:
isClassin interfaceResolvedTypeDeclaration
-
isInterface
public boolean isInterface()Description copied from interface:ResolvedTypeDeclarationIs this the declaration of an interface?- Specified by:
isInterfacein interfaceResolvedTypeDeclaration
-
getPackageName
Description copied from interface:ResolvedTypeDeclarationThe package name of the type.- Specified by:
getPackageNamein interfaceResolvedTypeDeclaration
-
getClassName
Description copied from interface:ResolvedTypeDeclarationThe class(es) wrapping this type.- Specified by:
getClassNamein interfaceResolvedTypeDeclaration
-
getQualifiedName
Description copied from interface:ResolvedTypeDeclarationThe fully qualified name of the type declared.- Specified by:
getQualifiedNamein interfaceResolvedTypeDeclaration
-
isAssignableBy
Description copied from interface:ResolvedReferenceTypeDeclarationCan we assign instances of the given type to variables having the type defined by this declaration?- Specified by:
isAssignableByin interfaceResolvedReferenceTypeDeclaration
-
isAssignableBy
Description copied from interface:ResolvedReferenceTypeDeclarationCan we assign instances of the given type to variables having the type defined by this declaration?- Specified by:
isAssignableByin interfaceResolvedReferenceTypeDeclaration
-
isTypeParameter
public boolean isTypeParameter()Description copied from interface:ResolvedTypeDeclarationIs this the declaration of a type parameter?- Specified by:
isTypeParameterin interfaceResolvedTypeDeclaration
-
equals
-
hashCode
-
solveMethodAsUsage
public Optional<MethodUsage> solveMethodAsUsage(String name, List<ResolvedType> argumentTypes, Context invokationContext, List<ResolvedType> typeParameters) - Specified by:
solveMethodAsUsagein interfaceMethodUsageResolutionCapability
-
solveMethod
public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) - Specified by:
solveMethodin interfaceMethodResolutionCapability
-
solveSymbol
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) - Specified by:
solveSymbolin interfaceSymbolResolutionCapability- Parameters:
name- Field / symbol name.typeSolver- Symbol solver to resolve type usage.- Returns:
- Symbol reference of the resolved value.
-
getAllFields
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all fields, either declared in this declaration or inherited.- Specified by:
getAllFieldsin interfaceResolvedReferenceTypeDeclaration
-
getAncestors
Description copied from interface:ResolvedReferenceTypeDeclarationResolves the types of all direct ancestors (i.e., the directly extended class and the directly implemented interfaces) and returns the list of ancestors as a list of resolved reference types.If
acceptIncompleteListisfalse, then anUnsolvedSymbolExceptionis thrown if any ancestor cannot be resolved. Otherwise, a list of only the resolvable direct ancestors is returned.- Specified by:
getAncestorsin interfaceResolvedReferenceTypeDeclaration- Parameters:
acceptIncompleteList- When set tofalse, this method throws anUnsolvedSymbolExceptionif one or more ancestor could not be resolved. When set totrue, this method does not throw anUnsolvedSymbolException, but the list of returned ancestors may be incomplete in case one or more ancestor could not be resolved.- Returns:
- The list of resolved ancestors.
-
toReferenceType
-
solveType
Deprecated.This method is deprecated because it receives the TypesSolver as a parameter. Eventually we would like to remove all usages of TypeSolver as a parameter. Also, resolution should move out of declarations, so that they are pure declarations and the resolution should work for JavaParser, Reflection and Javassist classes in the same way and not be specific to the three implementations. -
getTypeParameters
Description copied from interface:ResolvedTypeParametrizableThe list of type parameters defined on this element.- Specified by:
getTypeParametersin interfaceResolvedTypeParametrizable
-
getWrappedNode
Returns the JavaParser node associated with this JavaParserEnumDeclaration.- Returns:
- A visitable JavaParser node wrapped by this object.
-
getEnumConstants
- Specified by:
getEnumConstantsin interfaceResolvedEnumDeclaration
-
accessSpecifier
Description copied from interface:HasAccessSpecifierThe access specifier of this element.- Specified by:
accessSpecifierin interfaceHasAccessSpecifier
-
internalTypes
Description copied from interface:ResolvedTypeDeclarationGet the list of types defined inside the current type.- Specified by:
internalTypesin interfaceResolvedTypeDeclaration
-
containerType
Description copied from interface:ResolvedTypeDeclarationGet the ReferenceTypeDeclaration enclosing this declaration.- Specified by:
containerTypein interfaceResolvedTypeDeclaration
-
getConstructors
- Specified by:
getConstructorsin interfaceResolvedReferenceTypeDeclaration
-
toAst
Description copied from interface:AssociableToASTIf the declaration is associated to an AST node return it, otherwise it return empty. Declaration based on source code have an AST node associated while others don't. Example of other declarations are declarations coming from reflection or JARs. You may wonder how this method is different from the various getWrappedNode. The difference is that toAst is present in all Resolved* declarations (such as ResolvedAnnotationDeclaration), while getWrappedNode is present only on the subclasses of the Resolved* declarations that derive from JP AST nodes (such as JavaParserClassDeclaration). Therefore one which has a Resolved* declaration need to do a downcast before being able to use getWrappedNode. Now, this means that toAst could potentially replace getWrappedNode (but not the other way around!). However toAst return an Optional, which is less convenient than getting the direct node. Also, toAst sometimes have to return a more generic node. This is the case for subclasses of ResolvedClassDeclaration. In those cases toAst return a Node. Why? Because both anonymous class declarations and standard class declarations are subclasses of that. In one case the underlying AST node is an ObjectCreationExpr, while in the other case it is ClassOrInterfaceDeclaration. In these cases getWrappedNode is particularly nice because it returns the right type of AST node, not just a Node.- Specified by:
toAstin interfaceAssociableToAST
-