Class ReflectionRecordDeclaration
java.lang.Object
com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
com.github.javaparser.symbolsolver.reflectionmodel.ReflectionRecordDeclaration
- All Implemented Interfaces:
AssociableToAST
,HasAccessSpecifier
,ResolvedDeclaration
,ResolvedRecordDeclaration
,ResolvedReferenceTypeDeclaration
,ResolvedTypeDeclaration
,ResolvedTypeParametrizable
,MethodResolutionCapability
,MethodUsageResolutionCapability
public class ReflectionRecordDeclaration
extends AbstractTypeDeclaration
implements ResolvedRecordDeclaration, MethodResolutionCapability, MethodUsageResolutionCapability
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Class
<?> private ReflectionClassAdapter
private 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 -
Method Summary
Modifier and TypeMethodDescriptionThe access specifier of this element.boolean
Can we assign instances of the type defined by this declaration to variables having the type defined by the given type?Get the ReferenceTypeDeclaration enclosing this declaration.boolean
Return a list of all fields, either declared in this declaration or inherited.Return all the interfaces implemented by this class, either directly or indirectly, including the interfaces extended by interfaces it implements.Get all superclasses, with all the type typeParametersValues expressed as functions of the type typeParametersValues of this declaration.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.List of constructors available for the class.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.Return all the interfaces implemented directly by this class.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.This is a ReferenceTypeUsage because it could contain type typeParametersValues.The list of type parameters defined on this element.boolean
hasDirectlyAnnotation
(String canonicalName) Has the type at least one annotation declared having the specified qualified name?boolean
Has this type a field with the given name?int
hashCode()
Get the list of types defined inside the current type.boolean
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
isField()
Does this declaration represents a class field?boolean
Is this the declaration of an interface?boolean
Does this declaration represents a method parameter?boolean
isRecord()
Is this the declaration of a record class?boolean
isType()
Does this declaration represents a type?boolean
Is this the declaration of a type parameter?protected ResolvedReferenceType
object()
protected ResolvedReferenceType
record()
solveMethod
(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) Deprecated.solveMethodAsUsage
(String name, List<ResolvedType> argumentsTypes, Context invokationContext, List<ResolvedType> typeParameterValues) SymbolReference
<? extends ResolvedValueDeclaration> solveSymbol
(String name, TypeSolver typeSolver) Deprecated.toAst()
If the declaration is associated to an AST node return it, otherwise it return empty.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
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedDeclaration
asEnumConstant, asField, asMethod, asParameter, asTypePattern, hasName, isEnumConstant, isMethod, isTypePattern, isVariable
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedRecordDeclaration
asRecord
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, asInterface, asType, asTypeParameter, getId, getInternalType, hasInternalType, isAnnotation, isAnonymousClass, isClass, isEnum
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable
isGeneric
-
Field Details
-
clazz
-
typeSolver
-
reflectionClassAdapter
-
-
Constructor Details
-
ReflectionRecordDeclaration
-
-
Method Details
-
getDeclaredMethods
Description copied from interface:ResolvedReferenceTypeDeclaration
Return a list of all the methods declared in this type declaration.- Specified by:
getDeclaredMethods
in interfaceResolvedReferenceTypeDeclaration
-
getAncestors
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.
-
equals
-
hashCode
public int hashCode() -
getPackageName
Description copied from interface:ResolvedTypeDeclaration
The package name of the type.- Specified by:
getPackageName
in interfaceResolvedTypeDeclaration
-
getClassName
Description copied from interface:ResolvedTypeDeclaration
The class(es) wrapping this type.- Specified by:
getClassName
in interfaceResolvedTypeDeclaration
-
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(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) Deprecated.- Specified by:
solveMethod
in interfaceMethodResolutionCapability
-
toString
-
getUsage
-
solveMethodAsUsage
public Optional<MethodUsage> solveMethodAsUsage(String name, List<ResolvedType> argumentsTypes, Context invokationContext, List<ResolvedType> typeParameterValues) - Specified by:
solveMethodAsUsage
in interfaceMethodUsageResolutionCapability
-
canBeAssignedTo
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
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
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
Description copied from interface:ResolvedReferenceTypeDeclaration
Return a list of all fields, either declared in this declaration or inherited.- Specified by:
getAllFields
in interfaceResolvedReferenceTypeDeclaration
-
solveSymbol
@Deprecated public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) Deprecated. -
hasDirectlyAnnotation
Description copied from interface:ResolvedReferenceTypeDeclaration
Has the type at least one annotation declared having the specified qualified name?- Specified by:
hasDirectlyAnnotation
in interfaceResolvedReferenceTypeDeclaration
-
hasField
Description copied from interface:ResolvedReferenceTypeDeclaration
Has this type a field with the given name?- Specified by:
hasField
in interfaceResolvedReferenceTypeDeclaration
-
isAssignableBy
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
-
getName
Description copied from interface:ResolvedDeclaration
Should return the name or return null if the name is not available.- Specified by:
getName
in interfaceResolvedDeclaration
-
isField
public boolean isField()Description copied from interface:ResolvedDeclaration
Does this declaration represents a class field?- Specified by:
isField
in interfaceResolvedDeclaration
-
isParameter
public boolean isParameter()Description copied from interface:ResolvedDeclaration
Does this declaration represents a method parameter?- Specified by:
isParameter
in interfaceResolvedDeclaration
-
isType
public boolean isType()Description copied from interface:ResolvedDeclaration
Does this declaration represents a type?- Specified by:
isType
in interfaceResolvedDeclaration
- Specified by:
isType
in interfaceResolvedTypeDeclaration
-
isRecord
public boolean isRecord()Description copied from interface:ResolvedTypeDeclaration
Is this the declaration of a record class?- Specified by:
isRecord
in interfaceResolvedRecordDeclaration
- Specified by:
isRecord
in interfaceResolvedTypeDeclaration
-
getSuperClass
Description copied from interface:ResolvedRecordDeclaration
This is a ReferenceTypeUsage because it could contain type typeParametersValues. For example:class A extends B<Integer, String>
.Note that only the Object class should not have a superclass and therefore return empty.
- Specified by:
getSuperClass
in interfaceResolvedRecordDeclaration
-
getAllSuperClasses
Description copied from interface:ResolvedRecordDeclaration
Get all superclasses, with all the type typeParametersValues expressed as functions of the type typeParametersValues of this declaration.- Specified by:
getAllSuperClasses
in interfaceResolvedRecordDeclaration
-
getInterfaces
Description copied from interface:ResolvedRecordDeclaration
Return all the interfaces implemented directly by this class. It does not include the interfaces implemented by superclasses or extended by the interfaces implemented.- Specified by:
getInterfaces
in interfaceResolvedRecordDeclaration
-
getAllInterfaces
Description copied from interface:ResolvedRecordDeclaration
Return all the interfaces implemented by this class, either directly or indirectly, including the interfaces extended by interfaces it implements.Get all interfaces, with all the type typeParametersValues expressed as functions of the type typeParametersValues of this declaration.
- Specified by:
getAllInterfaces
in interfaceResolvedRecordDeclaration
-
isInterface
public boolean isInterface()Description copied from interface:ResolvedTypeDeclaration
Is this the declaration of an interface?- Specified by:
isInterface
in interfaceResolvedTypeDeclaration
-
getTypeParameters
Description copied from interface:ResolvedTypeParametrizable
The list of type parameters defined on this element.- Specified by:
getTypeParameters
in interfaceResolvedTypeParametrizable
-
accessSpecifier
Description copied from interface:HasAccessSpecifier
The access specifier of this element.- Specified by:
accessSpecifier
in interfaceHasAccessSpecifier
-
getConstructors
Description copied from interface:ResolvedRecordDeclaration
List of constructors available for the class. This list should also include the default constructor.- Specified by:
getConstructors
in interfaceResolvedRecordDeclaration
- Specified by:
getConstructors
in interfaceResolvedReferenceTypeDeclaration
-
containerType
Description copied from interface:ResolvedTypeDeclaration
Get the ReferenceTypeDeclaration enclosing this declaration.- Specified by:
containerType
in interfaceResolvedTypeDeclaration
-
internalTypes
Description copied from interface:ResolvedTypeDeclaration
Get the list of types defined inside the current type.- Specified by:
internalTypes
in interfaceResolvedTypeDeclaration
-
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
-
record
-
object
-