Class JavaParserTypeVariableDeclaration
java.lang.Object
com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserTypeVariableDeclaration
- All Implemented Interfaces:
AssociableToAST, ResolvedDeclaration, ResolvedReferenceTypeDeclaration, ResolvedTypeDeclaration, ResolvedTypeParametrizable
-
Field Summary
FieldsFields inherited from interface ResolvedReferenceTypeDeclaration
breadthFirstFunc, depthFirstFunc, JAVA_IO_SERIALIZABLE, JAVA_LANG_COMPARABLE, JAVA_LANG_ENUM, JAVA_LANG_OBJECT, JAVA_LANG_RECORD -
Constructor Summary
ConstructorsConstructorDescriptionJavaParserTypeVariableDeclaration(TypeParameter wrappedNode, TypeSolver typeSolver) -
Method Summary
Modifier and TypeMethodDescriptionReturn this as a TypeParameterDeclaration or throw UnsupportedOperationException.Get the ReferenceTypeDeclaration enclosing this declaration.Return 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.Note that the type of the field should be expressed using the type variables of this particular type.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 JavaParserTypeVariableDeclaration.booleanhasDirectlyAnnotation(String canonicalName) Has the type at least one annotation declared having the specified qualified name?booleanHas this type a field with the given name?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.booleanIs this the declaration of an interface?booleanisType()Does this declaration represents a type?booleanIs this the declaration of a type parameter?solveMethod(String name, List<ResolvedType> parameterTypes) toAst()If the declaration is associated to an AST node return it, otherwise it return empty.toString()Methods inherited from class AbstractTypeDeclaration
getAllMethods, isFunctionalInterface, isRecordTypeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AssociableToAST
toAstMethods inherited from interface ResolvedDeclaration
asEnumConstant, asField, asMethod, asParameter, asTypePattern, hasName, isEnumConstant, isField, isMethod, isParameter, isTypePattern, isVariableMethods inherited from interface ResolvedReferenceTypeDeclaration
asReferenceType, canBeAssignedTo, findTypeParameter, getAllAncestors, getAllAncestors, getAllNonStaticFields, getAllStaticFields, getAncestors, getDeclaredAnnotation, getDeclaredAnnotations, getDeclaredFields, getVisibleField, getVisibleFields, hasAnnotation, hasVisibleField, isInheritedAnnotation, isJavaLangEnum, isJavaLangObject, isJavaLangRecord, isReferenceTypeMethods inherited from interface ResolvedTypeDeclaration
asAnnotation, asClass, asEnum, asInterface, asRecord, asType, getId, getInternalType, hasInternalType, internalTypes, isAnnotation, isAnonymousClass, isEnum, isRecordMethods inherited from interface ResolvedTypeParametrizable
isGeneric
-
Field Details
-
wrappedNode
-
typeSolver
-
-
Constructor Details
-
JavaParserTypeVariableDeclaration
-
-
Method Details
-
isAssignableBy
Description copied from interface:ResolvedReferenceTypeDeclarationCan we assign instances of the given type to variables having the type defined by this declaration? -
getPackageName
Description copied from interface:ResolvedTypeDeclarationThe package name of the type. -
getClassName
Description copied from interface:ResolvedTypeDeclarationThe class(es) wrapping this type. -
getQualifiedName
Description copied from interface:ResolvedTypeDeclarationThe fully qualified name of the type declared. -
getContext
-
toString
-
solveMethod
public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> parameterTypes) -
getUsage
-
isAssignableBy
Description copied from interface:ResolvedReferenceTypeDeclarationCan we assign instances of the given type to variables having the type defined by this declaration? -
isTypeParameter
public boolean isTypeParameter()Description copied from interface:ResolvedTypeDeclarationIs this the declaration of a type parameter? -
getField
Description copied from interface:ResolvedReferenceTypeDeclarationNote that the type of the field should be expressed using the type variables of this particular type. Consider for example:class Foo
{ E field; } class Bar extends Foo
{ } When calling getField("field") on Foo I should get a FieldDeclaration with type E, while calling it on Bar I should get a FieldDeclaration with type String.
-
hasField
Description copied from interface:ResolvedReferenceTypeDeclarationHas this type a field with the given name? -
getAllFields
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all fields, either declared in this declaration or inherited. -
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.- 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.
-
getDeclaredMethods
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all the methods declared in this type declaration. -
getName
Description copied from interface:ResolvedDeclarationShould return the name or return null if the name is not available. -
isType
public boolean isType()Description copied from interface:ResolvedDeclarationDoes this declaration represents a type? -
hasDirectlyAnnotation
Description copied from interface:ResolvedReferenceTypeDeclarationHas the type at least one annotation declared having the specified qualified name? -
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. -
isInterface
public boolean isInterface()Description copied from interface:ResolvedTypeDeclarationIs this the declaration of an interface? -
getTypeParameters
Description copied from interface:ResolvedTypeParametrizableThe list of type parameters defined on this element. -
asTypeParameter
Description copied from interface:ResolvedTypeDeclarationReturn this as a TypeParameterDeclaration or throw UnsupportedOperationException. -
getWrappedNode
Returns the JavaParser node associated with this JavaParserTypeVariableDeclaration.- Returns:
- A visitable JavaParser node wrapped by this object.
-
containerType
Description copied from interface:ResolvedTypeDeclarationGet the ReferenceTypeDeclaration enclosing this declaration. -
getConstructors
-
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.
-