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

public class JavaParserTypeVariableDeclaration extends AbstractTypeDeclaration
  • Field Details

  • Constructor Details

    • JavaParserTypeVariableDeclaration

      public JavaParserTypeVariableDeclaration(TypeParameter wrappedNode, TypeSolver typeSolver)
  • Method Details

    • isAssignableBy

      public boolean isAssignableBy(ResolvedReferenceTypeDeclaration other)
      Description copied from interface: ResolvedReferenceTypeDeclaration
      Can we assign instances of the given type to variables having the type defined by this declaration?
    • getPackageName

      public String getPackageName()
      Description copied from interface: ResolvedTypeDeclaration
      The package name of the type.
    • getClassName

      public String getClassName()
      Description copied from interface: ResolvedTypeDeclaration
      The class(es) wrapping this type.
    • getQualifiedName

      public String getQualifiedName()
      Description copied from interface: ResolvedTypeDeclaration
      The fully qualified name of the type declared.
    • getContext

      public Context getContext()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • solveMethod

      public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> parameterTypes)
    • getUsage

      public ResolvedType getUsage(Node node)
    • isAssignableBy

      public boolean isAssignableBy(ResolvedType type)
      Description copied from interface: ResolvedReferenceTypeDeclaration
      Can we assign instances of the given type to variables having the type defined by this declaration?
    • isTypeParameter

      public boolean isTypeParameter()
      Description copied from interface: ResolvedTypeDeclaration
      Is this the declaration of a type parameter?
    • getField

      public ResolvedFieldDeclaration getField(String name)
      Description copied from interface: ResolvedReferenceTypeDeclaration
      Note 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

      public boolean hasField(String name)
      Description copied from interface: ResolvedReferenceTypeDeclaration
      Has this type a field with the given name?
    • getAllFields

      public List<ResolvedFieldDeclaration> getAllFields()
      Description copied from interface: ResolvedReferenceTypeDeclaration
      Return a list of all fields, either declared in this declaration or inherited.
    • getAncestors

      public List<ResolvedReferenceType> getAncestors(boolean acceptIncompleteList)
      Description copied from interface: ResolvedReferenceTypeDeclaration
      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.

      If acceptIncompleteList is false, then an UnsolvedSymbolException is thrown if any ancestor cannot be resolved. Otherwise, a list of only the resolvable direct ancestors is returned.

      Parameters:
      acceptIncompleteList - When set to false, this method throws an UnsolvedSymbolException if one or more ancestor could not be resolved. When set to true, this method does not throw an UnsolvedSymbolException, 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

      public Set<ResolvedMethodDeclaration> getDeclaredMethods()
      Description copied from interface: ResolvedReferenceTypeDeclaration
      Return a list of all the methods declared in this type declaration.
    • getName

      public String getName()
      Description copied from interface: ResolvedDeclaration
      Should return the name or return null if the name is not available.
    • isType

      public boolean isType()
      Description copied from interface: ResolvedDeclaration
      Does this declaration represents a type?
    • hasDirectlyAnnotation

      public boolean hasDirectlyAnnotation(String canonicalName)
      Description copied from interface: ResolvedReferenceTypeDeclaration
      Has the type at least one annotation declared having the specified qualified name?
    • isClass

      public boolean isClass()
      Description copied from interface: ResolvedTypeDeclaration
      Is 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: ResolvedTypeDeclaration
      Is this the declaration of an interface?
    • getTypeParameters

      public List<ResolvedTypeParameterDeclaration> getTypeParameters()
      Description copied from interface: ResolvedTypeParametrizable
      The list of type parameters defined on this element.
    • asTypeParameter

      public ResolvedTypeParameterDeclaration asTypeParameter()
      Description copied from interface: ResolvedTypeDeclaration
      Return this as a TypeParameterDeclaration or throw UnsupportedOperationException.
    • getWrappedNode

      public TypeParameter getWrappedNode()
      Returns the JavaParser node associated with this JavaParserTypeVariableDeclaration.
      Returns:
      A visitable JavaParser node wrapped by this object.
    • containerType

      public Optional<ResolvedReferenceTypeDeclaration> containerType()
      Description copied from interface: ResolvedTypeDeclaration
      Get the ReferenceTypeDeclaration enclosing this declaration.
    • getConstructors

      public List<ResolvedConstructorDeclaration> getConstructors()
    • toAst

      public Optional<Node> toAst()
      Description copied from interface: AssociableToAST
      If 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.