Class JavaParserTypeParameter
- java.lang.Object
-
- com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
-
- com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserTypeParameter
-
- All Implemented Interfaces:
AssociableToAST,ResolvedDeclaration,ResolvedReferenceTypeDeclaration,ResolvedTypeDeclaration,ResolvedTypeParameterDeclaration,ResolvedTypeParametrizable
public class JavaParserTypeParameter extends AbstractTypeDeclaration implements ResolvedTypeParameterDeclaration
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration
ResolvedTypeParameterDeclaration.Bound
-
-
Field Summary
Fields Modifier and Type Field Description private TypeSolvertypeSolverprivate TypeParameterwrappedNode-
Fields inherited from interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
breadthFirstFunc, depthFirstFunc, JAVA_IO_SERIALIZABLE, JAVA_LANG_COMPARABLE, JAVA_LANG_ENUM, JAVA_LANG_OBJECT, JAVA_LANG_RECORD
-
-
Constructor Summary
Constructors Constructor Description JavaParserTypeParameter(TypeParameter wrappedNode, TypeSolver typeSolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResolvedTypeParameterDeclarationasTypeParameter()Return this as a TypeParameterDeclaration or throw UnsupportedOperationException.java.util.Optional<ResolvedReferenceTypeDeclaration>containerType()Get the ReferenceTypeDeclaration enclosing this declaration.booleanequals(java.lang.Object o)java.util.List<ResolvedFieldDeclaration>getAllFields()Return a list of all fields, either declared in this declaration or inherited.java.util.List<ResolvedReferenceType>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.java.util.List<ResolvedTypeParameterDeclaration.Bound>getBounds()The bounds specified for the type parameter.java.util.List<ResolvedConstructorDeclaration>getConstructors()ResolvedTypeParametrizablegetContainer()The TypeParametrizable of the container.java.lang.StringgetContainerId()The ID of the container.java.lang.StringgetContainerQualifiedName()The qualified name of the container.ContextgetContext()java.util.Set<ResolvedMethodDeclaration>getDeclaredMethods()Return a list of all the methods declared in this type declaration.ResolvedFieldDeclarationgetField(java.lang.String name)Note that the type of the field should be expressed using the type variables of this particular type.java.lang.StringgetName()Name of the type parameter.java.lang.StringgetQualifiedName()The qualified name of the Type Parameter.java.util.List<ResolvedTypeParameterDeclaration>getTypeParameters()The list of type parameters defined on this element.ResolvedTypegetUsage(Node node)TypeParametergetWrappedNode()Returns the JavaParser node associated with this JavaParserTypeParameter.booleanhasDirectlyAnnotation(java.lang.String canonicalName)Has the type at least one annotation declared having the specified qualified name?booleanhasField(java.lang.String name)Has this type a field with the given name?inthashCode()booleanisAssignableBy(ResolvedReferenceTypeDeclaration other)Can 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?booleanisTypeParameter()Is this the declaration of a type parameter?ResolvedReferenceTypeobject()SymbolReference<ResolvedMethodDeclaration>solveMethod(java.lang.String name, java.util.List<ResolvedType> parameterTypes)java.util.Optional<Node>toAst()If the declaration is associated to an AST node return it, otherwise it return empty.private ResolvedTypeParameterDeclaration.BoundtoBound(ClassOrInterfaceType classOrInterfaceType, TypeSolver typeSolver)java.lang.StringtoString()-
Methods inherited from class com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
getAllMethods, isFunctionalInterface, isRecordType
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.resolution.declarations.AssociableToAST
toAst
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedDeclaration
asEnumConstant, asField, asMethod, asParameter, asTypePattern, hasName, isEnumConstant, isField, isMethod, isParameter, isTypePattern, isVariable
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
asReferenceType, canBeAssignedTo, findTypeParameter, getAllAncestors, getAllAncestors, getAllNonStaticFields, getAllStaticFields, getAncestors, getDeclaredAnnotation, getDeclaredAnnotations, getDeclaredFields, getVisibleField, getVisibleFields, hasAnnotation, hasVisibleField, isInheritedAnnotation, isJavaLangEnum, isJavaLangObject, isJavaLangRecord, isReferenceType
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration
asAnnotation, asClass, asEnum, asInterface, asRecord, asType, getId, getInternalType, hasInternalType, internalTypes, isAnnotation, isAnonymousClass, isClass, isEnum, isInterface, isRecord, isType
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParameterDeclaration
declaredOnConstructor, declaredOnMethod, declaredOnType, getClassName, getLowerBound, getPackageName, getUpperBound, hasBound, hasLowerBound, hasUpperBound, isBounded, isUnbounded
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable
isGeneric
-
-
-
-
Field Detail
-
wrappedNode
private TypeParameter wrappedNode
-
typeSolver
private TypeSolver typeSolver
-
-
Constructor Detail
-
JavaParserTypeParameter
public JavaParserTypeParameter(TypeParameter wrappedNode, TypeSolver typeSolver)
-
-
Method Detail
-
getDeclaredMethods
public java.util.Set<ResolvedMethodDeclaration> getDeclaredMethods()
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all the methods declared in this type declaration.- Specified by:
getDeclaredMethodsin interfaceResolvedReferenceTypeDeclaration
-
solveMethod
public SymbolReference<ResolvedMethodDeclaration> solveMethod(java.lang.String name, java.util.List<ResolvedType> parameterTypes)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getName
public java.lang.String getName()
Description copied from interface:ResolvedTypeParameterDeclarationName of the type parameter.- Specified by:
getNamein interfaceResolvedDeclaration- Specified by:
getNamein interfaceResolvedTypeParameterDeclaration
-
isAssignableBy
public boolean isAssignableBy(ResolvedReferenceTypeDeclaration other)
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
-
getContainerQualifiedName
public java.lang.String getContainerQualifiedName()
Description copied from interface:ResolvedTypeParameterDeclarationThe qualified name of the container.- Specified by:
getContainerQualifiedNamein interfaceResolvedTypeParameterDeclaration
-
getContainerId
public java.lang.String getContainerId()
Description copied from interface:ResolvedTypeParameterDeclarationThe ID of the container. See TypeContainer.getId- Specified by:
getContainerIdin interfaceResolvedTypeParameterDeclaration
-
getContainer
public ResolvedTypeParametrizable getContainer()
Description copied from interface:ResolvedTypeParameterDeclarationThe TypeParametrizable of the container. Can be either a ReferenceTypeDeclaration or a MethodLikeDeclaration- Specified by:
getContainerin interfaceResolvedTypeParameterDeclaration
-
getQualifiedName
public java.lang.String getQualifiedName()
Description copied from interface:ResolvedTypeParameterDeclarationThe qualified name of the Type Parameter. It is composed by the qualified name of the container followed by a dot and the name of the Type Parameter. The qualified name of a method is its qualified signature.- Specified by:
getQualifiedNamein interfaceResolvedTypeDeclaration- Specified by:
getQualifiedNamein interfaceResolvedTypeParameterDeclaration
-
getBounds
public java.util.List<ResolvedTypeParameterDeclaration.Bound> getBounds()
Description copied from interface:ResolvedTypeParameterDeclarationThe bounds specified for the type parameter. For example: "extends A" or "super B"- Specified by:
getBoundsin interfaceResolvedTypeParameterDeclaration
-
toBound
private ResolvedTypeParameterDeclaration.Bound toBound(ClassOrInterfaceType classOrInterfaceType, TypeSolver typeSolver)
-
getContext
public Context getContext()
-
getUsage
public ResolvedType getUsage(Node node)
-
isAssignableBy
public boolean isAssignableBy(ResolvedType type)
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
-
getField
public ResolvedFieldDeclaration getField(java.lang.String name)
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.
- Specified by:
getFieldin interfaceResolvedReferenceTypeDeclaration
-
hasField
public boolean hasField(java.lang.String name)
Description copied from interface:ResolvedReferenceTypeDeclarationHas this type a field with the given name?- Specified by:
hasFieldin interfaceResolvedReferenceTypeDeclaration
-
getAllFields
public java.util.List<ResolvedFieldDeclaration> getAllFields()
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all fields, either declared in this declaration or inherited.- Specified by:
getAllFieldsin interfaceResolvedReferenceTypeDeclaration
-
getAncestors
public java.util.List<ResolvedReferenceType> getAncestors(boolean acceptIncompleteList)
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.
-
isTypeParameter
public boolean isTypeParameter()
Description copied from interface:ResolvedTypeDeclarationIs this the declaration of a type parameter?- Specified by:
isTypeParameterin interfaceResolvedTypeDeclaration- Specified by:
isTypeParameterin interfaceResolvedTypeParameterDeclaration
-
asTypeParameter
public ResolvedTypeParameterDeclaration asTypeParameter()
Description copied from interface:ResolvedTypeDeclarationReturn this as a TypeParameterDeclaration or throw UnsupportedOperationException.- Specified by:
asTypeParameterin interfaceResolvedTypeDeclaration- Specified by:
asTypeParameterin interfaceResolvedTypeParameterDeclaration
-
hasDirectlyAnnotation
public boolean hasDirectlyAnnotation(java.lang.String canonicalName)
Description copied from interface:ResolvedReferenceTypeDeclarationHas the type at least one annotation declared having the specified qualified name?- Specified by:
hasDirectlyAnnotationin interfaceResolvedReferenceTypeDeclaration
-
getTypeParameters
public java.util.List<ResolvedTypeParameterDeclaration> getTypeParameters()
Description copied from interface:ResolvedTypeParametrizableThe list of type parameters defined on this element.- Specified by:
getTypeParametersin interfaceResolvedTypeParametrizable
-
getWrappedNode
public TypeParameter getWrappedNode()
Returns the JavaParser node associated with this JavaParserTypeParameter.- Returns:
- A visitable JavaParser node wrapped by this object.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
containerType
public java.util.Optional<ResolvedReferenceTypeDeclaration> containerType()
Description copied from interface:ResolvedTypeDeclarationGet the ReferenceTypeDeclaration enclosing this declaration.- Specified by:
containerTypein interfaceResolvedTypeDeclaration
-
getConstructors
public java.util.List<ResolvedConstructorDeclaration> getConstructors()
- Specified by:
getConstructorsin interfaceResolvedReferenceTypeDeclaration
-
object
public ResolvedReferenceType object()
- Specified by:
objectin interfaceResolvedTypeParameterDeclaration
-
toAst
public java.util.Optional<Node> 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
-
-