Class ReflectionInterfaceDeclaration
- java.lang.Object
-
- com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
-
- com.github.javaparser.symbolsolver.reflectionmodel.ReflectionInterfaceDeclaration
-
- All Implemented Interfaces:
AssociableToAST
,HasAccessSpecifier
,ResolvedDeclaration
,ResolvedInterfaceDeclaration
,ResolvedReferenceTypeDeclaration
,ResolvedTypeDeclaration
,ResolvedTypeParametrizable
,MethodResolutionCapability
,MethodUsageResolutionCapability
,SymbolResolutionCapability
public class ReflectionInterfaceDeclaration extends AbstractTypeDeclaration implements ResolvedInterfaceDeclaration, MethodResolutionCapability, MethodUsageResolutionCapability, SymbolResolutionCapability
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<?>
clazz
private ReflectionClassAdapter
reflectionClassAdapter
private TypeSolver
typeSolver
-
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 ReflectionInterfaceDeclaration(java.lang.Class<?> clazz, 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?java.util.Optional<ResolvedReferenceTypeDeclaration>
containerType()
Get the ReferenceTypeDeclaration enclosing this declaration.boolean
equals(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.lang.String
getClassName()
The class(es) wrapping this type.java.util.List<ResolvedConstructorDeclaration>
getConstructors()
java.util.Set<ResolvedMethodDeclaration>
getDeclaredMethods()
Return a list of all the methods declared in this type declaration.ResolvedFieldDeclaration
getField(java.lang.String name)
Note that the type of the field should be expressed using the type variables of this particular type.java.util.List<ResolvedReferenceType>
getInterfacesExtended()
Return the list of interfaces extended directly by this one.java.lang.String
getName()
Should return the name or return null if the name is not available.java.lang.String
getPackageName()
The package name of the type.java.lang.String
getQualifiedName()
The fully qualified name of the type declared.java.util.List<ResolvedTypeParameterDeclaration>
getTypeParameters()
The list of type parameters defined on this element.ResolvedType
getUsage(Node node)
boolean
hasDirectlyAnnotation(java.lang.String canonicalName)
Has the type at least one annotation declared having the specified qualified name?boolean
hasField(java.lang.String name)
Has this type a field with the given name?int
hashCode()
java.util.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(java.lang.String name, java.util.List<ResolvedType> parameterTypes, boolean staticOnly)
Deprecated.java.util.Optional<MethodUsage>
solveMethodAsUsage(java.lang.String name, java.util.List<ResolvedType> parameterTypes, Context invokationContext, java.util.List<ResolvedType> typeParameterValues)
SymbolReference<? extends ResolvedValueDeclaration>
solveSymbol(java.lang.String name, TypeSolver typeSolver)
java.lang.String
toString()
-
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, 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.ResolvedInterfaceDeclaration
getAllInterfacesExtended
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
asReferenceType, findTypeParameter, getAllAncestors, getAllAncestors, getAllMethods, getAllNonStaticFields, getAllStaticFields, getAncestors, getDeclaredAnnotation, getDeclaredAnnotations, getDeclaredFields, getVisibleField, getVisibleFields, hasAnnotation, hasVisibleField, isFunctionalInterface, isInheritedAnnotation, isJavaLangEnum, isJavaLangObject, isJavaLangRecord, isReferenceType
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration
asAnnotation, asClass, asEnum, asRecord, asType, asTypeParameter, getId, getInternalType, hasInternalType, isAnnotation, isAnonymousClass, isClass, isEnum, isRecord, isType
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable
isGeneric
-
-
-
-
Field Detail
-
clazz
private java.lang.Class<?> clazz
-
typeSolver
private TypeSolver typeSolver
-
reflectionClassAdapter
private ReflectionClassAdapter reflectionClassAdapter
-
-
Constructor Detail
-
ReflectionInterfaceDeclaration
public ReflectionInterfaceDeclaration(java.lang.Class<?> clazz, TypeSolver typeSolver)
-
-
Method Detail
-
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
-
getPackageName
public java.lang.String getPackageName()
Description copied from interface:ResolvedTypeDeclaration
The package name of the type.- Specified by:
getPackageName
in interfaceResolvedTypeDeclaration
-
getClassName
public java.lang.String getClassName()
Description copied from interface:ResolvedTypeDeclaration
The class(es) wrapping this type.- Specified by:
getClassName
in interfaceResolvedTypeDeclaration
-
getQualifiedName
public java.lang.String getQualifiedName()
Description copied from interface:ResolvedTypeDeclaration
The fully qualified name of the type declared.- Specified by:
getQualifiedName
in interfaceResolvedTypeDeclaration
-
solveMethod
@Deprecated public SymbolReference<ResolvedMethodDeclaration> solveMethod(java.lang.String name, java.util.List<ResolvedType> parameterTypes, boolean staticOnly)
Deprecated.- Specified by:
solveMethod
in interfaceMethodResolutionCapability
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getUsage
public ResolvedType getUsage(Node node)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
solveMethodAsUsage
public java.util.Optional<MethodUsage> solveMethodAsUsage(java.lang.String name, java.util.List<ResolvedType> parameterTypes, Context invokationContext, java.util.List<ResolvedType> typeParameterValues)
- Specified by:
solveMethodAsUsage
in interfaceMethodUsageResolutionCapability
-
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
-
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
-
isTypeParameter
public boolean isTypeParameter()
Description copied from interface:ResolvedTypeDeclaration
Is this the declaration of a type parameter?- Specified by:
isTypeParameter
in interfaceResolvedTypeDeclaration
-
getField
public ResolvedFieldDeclaration getField(java.lang.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.
- Specified by:
getField
in interfaceResolvedReferenceTypeDeclaration
-
getAllFields
public java.util.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
-
solveSymbol
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(java.lang.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 java.util.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.
-
getDeclaredMethods
public java.util.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
-
hasField
public boolean hasField(java.lang.String name)
Description copied from interface:ResolvedReferenceTypeDeclaration
Has this type a field with the given name?- Specified by:
hasField
in interfaceResolvedReferenceTypeDeclaration
-
getName
public java.lang.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
-
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 java.util.List<ResolvedReferenceType> getInterfacesExtended()
Description copied from interface:ResolvedInterfaceDeclaration
Return the list of interfaces extended directly by this one.- Specified by:
getInterfacesExtended
in interfaceResolvedInterfaceDeclaration
-
containerType
public java.util.Optional<ResolvedReferenceTypeDeclaration> containerType()
Description copied from interface:ResolvedTypeDeclaration
Get the ReferenceTypeDeclaration enclosing this declaration.- Specified by:
containerType
in interfaceResolvedTypeDeclaration
-
internalTypes
public java.util.Set<ResolvedReferenceTypeDeclaration> internalTypes()
Description copied from interface:ResolvedTypeDeclaration
Get the list of types defined inside the current type.- Specified by:
internalTypes
in interfaceResolvedTypeDeclaration
-
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(java.lang.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
-
getTypeParameters
public java.util.List<ResolvedTypeParameterDeclaration> getTypeParameters()
Description copied from interface:ResolvedTypeParametrizable
The list of type parameters defined on this element.- Specified by:
getTypeParameters
in interfaceResolvedTypeParametrizable
-
accessSpecifier
public AccessSpecifier accessSpecifier()
Description copied from interface:HasAccessSpecifier
The access specifier of this element.- Specified by:
accessSpecifier
in interfaceHasAccessSpecifier
-
getConstructors
public java.util.List<ResolvedConstructorDeclaration> getConstructors()
- Specified by:
getConstructors
in interfaceResolvedReferenceTypeDeclaration
-
-