Class JavaParserInterfaceDeclaration
- java.lang.Object
-
- com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
-
- com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration
-
- All Implemented Interfaces:
AssociableToAST
,HasAccessSpecifier
,ResolvedDeclaration
,ResolvedInterfaceDeclaration
,ResolvedReferenceTypeDeclaration
,ResolvedTypeDeclaration
,ResolvedTypeParametrizable
,MethodResolutionCapability
,MethodUsageResolutionCapability
,SymbolResolutionCapability
public class JavaParserInterfaceDeclaration extends AbstractTypeDeclaration implements ResolvedInterfaceDeclaration, MethodResolutionCapability, MethodUsageResolutionCapability, SymbolResolutionCapability
- Author:
- Federico Tomassetti
-
-
Field Summary
-
Fields inherited from interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
breadthFirstFunc, depthFirstFunc, JAVA_LANG_ENUM, JAVA_LANG_OBJECT
-
-
Constructor Summary
Constructors Constructor Description JavaParserInterfaceDeclaration(ClassOrInterfaceDeclaration wrappedNode, TypeSolver typeSolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AccessSpecifier
accessSpecifier()
The access specifier of this element.ResolvedInterfaceDeclaration
asInterface()
Return this as a InterfaceDeclaration or throw UnsupportedOperationException.boolean
canBeAssignedTo(ResolvedReferenceTypeDeclaration other)
Can we assign instances of the type defined by this declaration to variables having the type defined by the given type?Optional<ResolvedReferenceTypeDeclaration>
containerType()
Get the ReferenceTypeDeclaration enclosing this declaration.boolean
equals(Object o)
List<ResolvedFieldDeclaration>
getAllFields()
Return a list of all fields, either declared in this declaration or inherited.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.String
getClassName()
The class(es) wrapping this type.List<ResolvedConstructorDeclaration>
getConstructors()
Context
getContext()
Set<ResolvedMethodDeclaration>
getDeclaredMethods()
Return a list of all the methods declared in this type declaration.List<ResolvedReferenceType>
getInterfacesExtended()
Return the list of interfaces extended directly by this one.String
getName()
Should return the name or return null if the name is not available.String
getPackageName()
The package name of the type.String
getQualifiedName()
The fully qualified name of the type declared.List<ResolvedTypeParameterDeclaration>
getTypeParameters()
The list of type parameters defined on this element.ResolvedType
getUsage(Node node)
ClassOrInterfaceDeclaration
getWrappedNode()
Returns the JavaParser node associated with this JavaParserInterfaceDeclaration.boolean
hasDirectlyAnnotation(String canonicalName)
Has the type at least one annotation declared having the specified qualified name?int
hashCode()
Set<ResolvedReferenceTypeDeclaration>
internalTypes()
Get the list of types defined inside the current type.boolean
isAssignableBy(ResolvedReferenceTypeDeclaration other)
Can we assign instances of the given type to variables having the type defined by this declaration?boolean
isAssignableBy(ResolvedType type)
Can we assign instances of the given type to variables having the type defined by this declaration?boolean
isInterface()
Is this the declaration of an interface?boolean
isTypeParameter()
Is this the declaration of a type parameter?SymbolReference<ResolvedMethodDeclaration>
solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly)
Optional<MethodUsage>
solveMethodAsUsage(String name, List<ResolvedType> argumentTypes, Context invocationContext, List<ResolvedType> typeParameters)
SymbolReference<? extends ResolvedValueDeclaration>
solveSymbol(String name, TypeSolver typeSolver)
SymbolReference<ResolvedTypeDeclaration>
solveType(String name)
Deprecated.Optional<Node>
toAst()
If the declaration is associated to an AST node return it, otherwise it return empty.String
toString()
-
Methods inherited from class com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
getAllMethods, isFunctionalInterface
-
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, asPattern, hasName, isEnumConstant, isField, isMethod, isParameter, isPattern, isVariable
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedInterfaceDeclaration
getAllInterfacesExtended
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
asReferenceType, findTypeParameter, getAllAncestors, getAllAncestors, getAllMethods, getAllNonStaticFields, getAllStaticFields, getAncestors, getDeclaredFields, getField, getVisibleField, getVisibleFields, hasAnnotation, hasField, hasVisibleField, isFunctionalInterface, isJavaLangEnum, isJavaLangObject, isReferenceType
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration
asAnnotation, asClass, asEnum, asType, asTypeParameter, getId, getInternalType, hasInternalType, isAnnotation, isAnonymousClass, isClass, isEnum, isType
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable
isGeneric
-
-
-
-
Constructor Detail
-
JavaParserInterfaceDeclaration
public JavaParserInterfaceDeclaration(ClassOrInterfaceDeclaration wrappedNode, TypeSolver typeSolver)
-
-
Method Detail
-
getDeclaredMethods
public Set<ResolvedMethodDeclaration> getDeclaredMethods()
Description copied from interface:ResolvedReferenceTypeDeclaration
Return a list of all the methods declared in this type declaration.- Specified by:
getDeclaredMethods
in interfaceResolvedReferenceTypeDeclaration
-
getContext
public Context getContext()
-
getUsage
public ResolvedType getUsage(Node node)
-
getName
public String getName()
Description copied from interface:ResolvedDeclaration
Should return the name or return null if the name is not available.- Specified by:
getName
in interfaceResolvedDeclaration
-
asInterface
public ResolvedInterfaceDeclaration asInterface()
Description copied from interface:ResolvedTypeDeclaration
Return this as a InterfaceDeclaration or throw UnsupportedOperationException.- Specified by:
asInterface
in interfaceResolvedTypeDeclaration
-
hasDirectlyAnnotation
public boolean hasDirectlyAnnotation(String canonicalName)
Description copied from interface:ResolvedReferenceTypeDeclaration
Has the type at least one annotation declared having the specified qualified name?- Specified by:
hasDirectlyAnnotation
in interfaceResolvedReferenceTypeDeclaration
-
isInterface
public boolean isInterface()
Description copied from interface:ResolvedTypeDeclaration
Is this the declaration of an interface?- Specified by:
isInterface
in interfaceResolvedInterfaceDeclaration
- Specified by:
isInterface
in interfaceResolvedTypeDeclaration
-
getInterfacesExtended
public List<ResolvedReferenceType> getInterfacesExtended()
Description copied from interface:ResolvedInterfaceDeclaration
Return the list of interfaces extended directly by this one.- Specified by:
getInterfacesExtended
in interfaceResolvedInterfaceDeclaration
-
getPackageName
public String getPackageName()
Description copied from interface:ResolvedTypeDeclaration
The package name of the type.- Specified by:
getPackageName
in interfaceResolvedTypeDeclaration
-
getClassName
public String getClassName()
Description copied from interface:ResolvedTypeDeclaration
The class(es) wrapping this type.- Specified by:
getClassName
in interfaceResolvedTypeDeclaration
-
getQualifiedName
public String getQualifiedName()
Description copied from interface:ResolvedTypeDeclaration
The fully qualified name of the type declared.- Specified by:
getQualifiedName
in interfaceResolvedTypeDeclaration
-
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?- Specified by:
isAssignableBy
in interfaceResolvedReferenceTypeDeclaration
-
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?- Specified by:
isAssignableBy
in interfaceResolvedReferenceTypeDeclaration
-
canBeAssignedTo
public boolean canBeAssignedTo(ResolvedReferenceTypeDeclaration other)
Description copied from interface:ResolvedReferenceTypeDeclaration
Can we assign instances of the type defined by this declaration to variables having the type defined by the given type?- Specified by:
canBeAssignedTo
in interfaceResolvedReferenceTypeDeclaration
-
isTypeParameter
public boolean isTypeParameter()
Description copied from interface:ResolvedTypeDeclaration
Is this the declaration of a type parameter?- Specified by:
isTypeParameter
in interfaceResolvedTypeDeclaration
-
getAllFields
public List<ResolvedFieldDeclaration> getAllFields()
Description copied from interface:ResolvedReferenceTypeDeclaration
Return a list of all fields, either declared in this declaration or inherited.- Specified by:
getAllFields
in interfaceResolvedReferenceTypeDeclaration
-
solveType
@Deprecated public SymbolReference<ResolvedTypeDeclaration> solveType(String name)
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.
-
solveMethod
public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly)
- Specified by:
solveMethod
in interfaceMethodResolutionCapability
-
solveMethodAsUsage
public Optional<MethodUsage> solveMethodAsUsage(String name, List<ResolvedType> argumentTypes, Context invocationContext, List<ResolvedType> typeParameters)
- Specified by:
solveMethodAsUsage
in interfaceMethodUsageResolutionCapability
-
solveSymbol
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver)
- Specified by:
solveSymbol
in interfaceSymbolResolutionCapability
- Parameters:
name
- Field / symbol name.typeSolver
- Symbol solver to resolve type usage.- Returns:
- Symbol reference of the resolved value.
-
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
isfalse
, then anUnsolvedSymbolException
is thrown if any ancestor cannot be resolved. Otherwise, a list of only the resolvable direct ancestors is returned.- Specified by:
getAncestors
in interfaceResolvedReferenceTypeDeclaration
- Parameters:
acceptIncompleteList
- When set tofalse
, this method throws anUnsolvedSymbolException
if 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.
-
getTypeParameters
public List<ResolvedTypeParameterDeclaration> getTypeParameters()
Description copied from interface:ResolvedTypeParametrizable
The list of type parameters defined on this element.- Specified by:
getTypeParameters
in interfaceResolvedTypeParametrizable
-
getWrappedNode
public ClassOrInterfaceDeclaration getWrappedNode()
Returns the JavaParser node associated with this JavaParserInterfaceDeclaration.- Returns:
- A visitable JavaParser node wrapped by this object.
-
accessSpecifier
public AccessSpecifier accessSpecifier()
Description copied from interface:HasAccessSpecifier
The access specifier of this element.- Specified by:
accessSpecifier
in interfaceHasAccessSpecifier
-
internalTypes
public Set<ResolvedReferenceTypeDeclaration> internalTypes()
Description copied from interface:ResolvedTypeDeclaration
Get the list of types defined inside the current type.- Specified by:
internalTypes
in interfaceResolvedTypeDeclaration
-
containerType
public Optional<ResolvedReferenceTypeDeclaration> containerType()
Description copied from interface:ResolvedTypeDeclaration
Get the ReferenceTypeDeclaration enclosing this declaration.- Specified by:
containerType
in interfaceResolvedTypeDeclaration
-
getConstructors
public List<ResolvedConstructorDeclaration> getConstructors()
- Specified by:
getConstructors
in interfaceResolvedReferenceTypeDeclaration
-
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.- Specified by:
toAst
in interfaceAssociableToAST
-
-