Class JavaParserMethodDeclaration
java.lang.Object
com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserMethodDeclaration
- All Implemented Interfaces:
AssociableToAST, HasAccessSpecifier, ResolvedDeclaration, ResolvedMethodDeclaration, ResolvedMethodLikeDeclaration, ResolvedTypeParametrizable, TypeVariableResolutionCapability
public class JavaParserMethodDeclaration
extends Object
implements ResolvedMethodDeclaration, TypeVariableResolutionCapability
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJavaParserMethodDeclaration(MethodDeclaration wrappedNode, TypeSolver typeSolver) -
Method Summary
Modifier and TypeMethodDescriptionThe access specifier of this element.The type in which the method is declared.private ContextgetName()Should return the name or return null if the name is not available.intNumber of params.intNumber of exceptions listed in the throws clause.getParam(int i) Get the ParameterDeclaration at the corresponding position or throw IllegalArgumentException.The type of the value returned by the current method.getSpecifiedException(int index) Type of the corresponding entry in the throws clause.The list of type parameters defined on this element.Returns the JavaParser node associated with this JavaParserMethodDeclaration.booleanIs the method abstract? All interface methods not marked as default are abstract.booleanIs this a default method?booleanisStatic()resolveTypeVariables(Context context, List<ResolvedType> parameterTypes) private SymbolResolversymbolResolver(TypeSolver typeSolver) toAst()If the declaration is associated to an AST node return it, otherwise it return empty.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AssociableToAST
toAstMethods inherited from interface ResolvedDeclaration
asEnumConstant, asField, asMethod, asParameter, asType, asTypePattern, hasName, isEnumConstant, isField, isMethod, isParameter, isType, isTypePattern, isVariableMethods inherited from interface ResolvedMethodDeclaration
isReturnTypeSubstituableMethods inherited from interface ResolvedMethodLikeDeclaration
findTypeParameter, formalParameterTypes, getClassName, getLastParam, getPackageName, getQualifiedName, getQualifiedSignature, getSignature, getSpecifiedExceptions, hasVariadicParameterMethods inherited from interface ResolvedTypeParametrizable
isGeneric
-
Field Details
-
wrappedNode
-
typeSolver
-
-
Constructor Details
-
JavaParserMethodDeclaration
-
-
Method Details
-
toString
-
declaringType
Description copied from interface:ResolvedMethodLikeDeclarationThe type in which the method is declared.- Specified by:
declaringTypein interfaceResolvedMethodLikeDeclaration
-
symbolResolver
-
getReturnType
Description copied from interface:ResolvedMethodDeclarationThe type of the value returned by the current method. This method can also be invoked for methods returning void.- Specified by:
getReturnTypein interfaceResolvedMethodDeclaration
-
getNumberOfParams
public int getNumberOfParams()Description copied from interface:ResolvedMethodLikeDeclarationNumber of params.- Specified by:
getNumberOfParamsin interfaceResolvedMethodLikeDeclaration
-
getParam
Description copied from interface:ResolvedMethodLikeDeclarationGet the ParameterDeclaration at the corresponding position or throw IllegalArgumentException.- Specified by:
getParamin interfaceResolvedMethodLikeDeclaration
-
getUsage
-
resolveTypeVariables
- Specified by:
resolveTypeVariablesin interfaceTypeVariableResolutionCapability
-
getContext
-
isAbstract
public boolean isAbstract()Description copied from interface:ResolvedMethodDeclarationIs the method abstract? All interface methods not marked as default are abstract.- Specified by:
isAbstractin interfaceResolvedMethodDeclaration
-
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
-
isDefaultMethod
public boolean isDefaultMethod()Description copied from interface:ResolvedMethodDeclarationIs this a default method?- Specified by:
isDefaultMethodin interfaceResolvedMethodDeclaration
-
isStatic
public boolean isStatic()- Specified by:
isStaticin interfaceResolvedMethodDeclaration
-
getWrappedNode
Returns the JavaParser node associated with this JavaParserMethodDeclaration.- Returns:
- A visitable JavaParser node wrapped by this object.
-
accessSpecifier
Description copied from interface:HasAccessSpecifierThe access specifier of this element.- Specified by:
accessSpecifierin interfaceHasAccessSpecifier
-
getNumberOfSpecifiedExceptions
public int getNumberOfSpecifiedExceptions()Description copied from interface:ResolvedMethodLikeDeclarationNumber of exceptions listed in the throws clause.- Specified by:
getNumberOfSpecifiedExceptionsin interfaceResolvedMethodLikeDeclaration
-
getSpecifiedException
Description copied from interface:ResolvedMethodLikeDeclarationType of the corresponding entry in the throws clause.- Specified by:
getSpecifiedExceptionin interfaceResolvedMethodLikeDeclaration
-
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
-
toDescriptor
- Specified by:
toDescriptorin interfaceResolvedMethodDeclaration
-