Class JavaParserAnonymousClassDeclaration
java.lang.Object
com.github.javaparser.symbolsolver.logic.AbstractTypeDeclaration
com.github.javaparser.symbolsolver.logic.AbstractClassDeclaration
com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserAnonymousClassDeclaration
- All Implemented Interfaces:
AssociableToAST, HasAccessSpecifier, ResolvedClassDeclaration, ResolvedDeclaration, ResolvedReferenceTypeDeclaration, ResolvedTypeDeclaration, ResolvedTypeParametrizable, MethodResolutionCapability, MethodUsageResolutionCapability
public class JavaParserAnonymousClassDeclaration
extends AbstractClassDeclaration
implements MethodUsageResolutionCapability
An anonymous class declaration representation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final ResolvedTypeDeclarationprivate final TypeSolverprivate final ObjectCreationExprFields inherited from interface ResolvedReferenceTypeDeclaration
breadthFirstFunc, depthFirstFunc, JAVA_IO_SERIALIZABLE, JAVA_LANG_COMPARABLE, JAVA_LANG_ENUM, JAVA_LANG_OBJECT, JAVA_LANG_RECORD -
Constructor Summary
ConstructorsConstructorDescriptionJavaParserAnonymousClassDeclaration(ObjectCreationExpr wrappedNode, TypeSolver typeSolver) -
Method Summary
Modifier and TypeMethodDescriptionThe access specifier of this element.Get the ReferenceTypeDeclaration enclosing this declaration.findMembersOfKind(Class<T> memberClass) Return a list of all fields, either declared in this declaration or inherited.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.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.booleanhasDirectlyAnnotation(String qualifiedName) Has the type at least one annotation declared having the specified qualified name?Get the list of types defined inside the current type.booleanCan 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?protected ResolvedReferenceTypeobject()An implementation of the Object class.solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) solveMethodAsUsage(String name, List<ResolvedType> argumentTypes, Context invocationContext, List<ResolvedType> typeParameters) toAst()If the declaration is associated to an AST node return it, otherwise it return empty.Methods inherited from class AbstractClassDeclaration
asClass, getAllInterfaces, getAllSuperClasses, hasNameMethods inherited from class AbstractTypeDeclaration
getAllMethods, isFunctionalInterface, isRecordTypeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AssociableToAST
toAstMethods inherited from interface ResolvedClassDeclaration
isClassMethods inherited from interface ResolvedDeclaration
asEnumConstant, asField, asMethod, asParameter, asTypePattern, isEnumConstant, isField, isMethod, isParameter, isTypePattern, isVariableMethods inherited from interface ResolvedReferenceTypeDeclaration
asReferenceType, canBeAssignedTo, findTypeParameter, getAllAncestors, getAllAncestors, getAllMethods, getAllNonStaticFields, getAllStaticFields, getAncestors, getDeclaredAnnotation, getDeclaredAnnotations, getDeclaredFields, getField, getVisibleField, getVisibleFields, hasAnnotation, hasField, hasVisibleField, isFunctionalInterface, isInheritedAnnotation, isJavaLangEnum, isJavaLangObject, isJavaLangRecord, isReferenceTypeMethods inherited from interface ResolvedTypeDeclaration
asAnnotation, asEnum, asInterface, asRecord, asType, asTypeParameter, getId, getInternalType, hasInternalType, isAnnotation, isAnonymousClass, isEnum, isInterface, isRecord, isType, isTypeParameterMethods inherited from interface ResolvedTypeParametrizable
isGeneric
-
Field Details
-
typeSolver
-
wrappedNode
-
superTypeDeclaration
-
name
-
-
Constructor Details
-
JavaParserAnonymousClassDeclaration
-
-
Method Details
-
getSuperTypeDeclaration
-
findMembersOfKind
-
getContext
-
solveMethod
public SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> argumentsTypes, boolean staticOnly) - Specified by:
solveMethodin interfaceMethodResolutionCapability
-
solveMethodAsUsage
public Optional<MethodUsage> solveMethodAsUsage(String name, List<ResolvedType> argumentTypes, Context invocationContext, List<ResolvedType> typeParameters) - Specified by:
solveMethodAsUsagein interfaceMethodUsageResolutionCapability
-
object
Description copied from class:AbstractClassDeclarationAn implementation of the Object class.- Specified by:
objectin classAbstractClassDeclaration
-
getSuperClass
Description copied from interface:ResolvedClassDeclarationThis 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:
getSuperClassin interfaceResolvedClassDeclaration
-
getInterfaces
Description copied from interface:ResolvedClassDeclarationReturn 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:
getInterfacesin interfaceResolvedClassDeclaration
-
getConstructors
Description copied from interface:ResolvedClassDeclarationList of constructors available for the class. This list should also include the default constructor.- Specified by:
getConstructorsin interfaceResolvedClassDeclaration- Specified by:
getConstructorsin interfaceResolvedReferenceTypeDeclaration
-
accessSpecifier
Description copied from interface:HasAccessSpecifierThe access specifier of this element.- Specified by:
accessSpecifierin interfaceHasAccessSpecifier
-
getAncestors
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.
-
getAllFields
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all fields, either declared in this declaration or inherited.- Specified by:
getAllFieldsin interfaceResolvedReferenceTypeDeclaration
-
getDeclaredMethods
Description copied from interface:ResolvedReferenceTypeDeclarationReturn a list of all the methods declared in this type declaration.- Specified by:
getDeclaredMethodsin interfaceResolvedReferenceTypeDeclaration
-
isAssignableBy
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
-
isAssignableBy
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
-
hasDirectlyAnnotation
Description copied from interface:ResolvedReferenceTypeDeclarationHas the type at least one annotation declared having the specified qualified name?- Specified by:
hasDirectlyAnnotationin interfaceResolvedReferenceTypeDeclaration
-
getPackageName
Description copied from interface:ResolvedTypeDeclarationThe package name of the type.- Specified by:
getPackageNamein interfaceResolvedTypeDeclaration
-
getClassName
Description copied from interface:ResolvedTypeDeclarationThe class(es) wrapping this type.- Specified by:
getClassNamein interfaceResolvedTypeDeclaration
-
getQualifiedName
Description copied from interface:ResolvedTypeDeclarationThe fully qualified name of the type declared.- Specified by:
getQualifiedNamein interfaceResolvedTypeDeclaration
-
internalTypes
Description copied from interface:ResolvedTypeDeclarationGet the list of types defined inside the current type.- Specified by:
internalTypesin interfaceResolvedTypeDeclaration
-
getName
Description copied from interface:ResolvedDeclarationShould return the name or return null if the name is not available.- Specified by:
getNamein interfaceResolvedDeclaration
-
getTypeParameters
Description copied from interface:ResolvedTypeParametrizableThe list of type parameters defined on this element.- Specified by:
getTypeParametersin interfaceResolvedTypeParametrizable
-
containerType
Description copied from interface:ResolvedTypeDeclarationGet the ReferenceTypeDeclaration enclosing this declaration.- Specified by:
containerTypein interfaceResolvedTypeDeclaration
-
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
-