Interface ResolvedMethodLikeDeclaration
-
- All Superinterfaces:
AssociableToAST
,HasAccessSpecifier
,ResolvedDeclaration
,ResolvedTypeParametrizable
- All Known Subinterfaces:
ResolvedConstructorDeclaration
,ResolvedMethodDeclaration
- All Known Implementing Classes:
DefaultConstructorDeclaration
,JavaParserConstructorDeclaration
,JavaParserEnumDeclaration.ValueOfMethod
,JavaParserEnumDeclaration.ValuesMethod
,JavaParserMethodDeclaration
,JavaParserRecordDeclaration.CanonicalRecordConstructor
,JavaParserRecordDeclaration.ImplicitGetterMethod
,JavassistConstructorDeclaration
,JavassistMethodDeclaration
,ReflectionConstructorDeclaration
,ReflectionMethodDeclaration
public interface ResolvedMethodLikeDeclaration extends ResolvedDeclaration, ResolvedTypeParametrizable, HasAccessSpecifier
This is a common interface for MethodDeclaration and ConstructorDeclaration.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ResolvedReferenceTypeDeclaration
declaringType()
The type in which the method is declared.default java.util.Optional<ResolvedTypeParameterDeclaration>
findTypeParameter(java.lang.String name)
Find the closest TypeParameterDeclaration with the given name.default java.util.List<ResolvedType>
formalParameterTypes()
default java.lang.String
getClassName()
The class(es) wrapping the declaring type.default ResolvedParameterDeclaration
getLastParam()
Utility method to get the last ParameterDeclaration.int
getNumberOfParams()
Number of params.int
getNumberOfSpecifiedExceptions()
Number of exceptions listed in the throws clause.default java.lang.String
getPackageName()
The package name of the declaring type.ResolvedParameterDeclaration
getParam(int i)
Get the ParameterDeclaration at the corresponding position or throw IllegalArgumentException.default java.lang.String
getQualifiedName()
The qualified name of the method composed by the qualfied name of the declaring type followed by a dot and the name of the method.default java.lang.String
getQualifiedSignature()
The qualified signature of the method.default java.lang.String
getSignature()
The signature of the method.ResolvedType
getSpecifiedException(int index)
Type of the corresponding entry in the throws clause.default java.util.List<ResolvedType>
getSpecifiedExceptions()
default boolean
hasVariadicParameter()
Has the method or construcor a variadic parameter? Note that when a method has a variadic parameter it should have an array type.-
Methods inherited from interface com.github.javaparser.resolution.declarations.AssociableToAST
toAst, toAst
-
Methods inherited from interface com.github.javaparser.resolution.declarations.HasAccessSpecifier
accessSpecifier
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedDeclaration
asEnumConstant, asField, asMethod, asParameter, asType, asTypePattern, getName, hasName, isEnumConstant, isField, isMethod, isParameter, isType, isTypePattern, isVariable
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable
getTypeParameters, isGeneric
-
-
-
-
Method Detail
-
getPackageName
default java.lang.String getPackageName()
The package name of the declaring type.
-
getClassName
default java.lang.String getClassName()
The class(es) wrapping the declaring type.
-
getQualifiedName
default java.lang.String getQualifiedName()
The qualified name of the method composed by the qualfied name of the declaring type followed by a dot and the name of the method.
-
getSignature
default java.lang.String getSignature()
The signature of the method.
-
getQualifiedSignature
default java.lang.String getQualifiedSignature()
The qualified signature of the method. It is composed by the qualified name of the declaring type followed by the signature of the method.
-
declaringType
ResolvedReferenceTypeDeclaration declaringType()
The type in which the method is declared.
-
getNumberOfParams
int getNumberOfParams()
Number of params.
-
getParam
ResolvedParameterDeclaration getParam(int i)
Get the ParameterDeclaration at the corresponding position or throw IllegalArgumentException.
-
getLastParam
default ResolvedParameterDeclaration getLastParam()
Utility method to get the last ParameterDeclaration. It throws UnsupportedOperationException if the method has no parameters. The last parameter can be variadic and sometimes it needs to be handled in a special way.
-
formalParameterTypes
default java.util.List<ResolvedType> formalParameterTypes()
-
hasVariadicParameter
default boolean hasVariadicParameter()
Has the method or construcor a variadic parameter? Note that when a method has a variadic parameter it should have an array type.
-
findTypeParameter
default java.util.Optional<ResolvedTypeParameterDeclaration> findTypeParameter(java.lang.String name)
Description copied from interface:ResolvedTypeParametrizable
Find the closest TypeParameterDeclaration with the given name. It first look on this element itself and then on the containers.- Specified by:
findTypeParameter
in interfaceResolvedTypeParametrizable
-
getNumberOfSpecifiedExceptions
int getNumberOfSpecifiedExceptions()
Number of exceptions listed in the throws clause.
-
getSpecifiedException
ResolvedType getSpecifiedException(int index)
Type of the corresponding entry in the throws clause.- Throws:
java.lang.IllegalArgumentException
- if the index is negative or it is equal or greater than the value returned by getNumberOfSpecifiedExceptionsjava.lang.UnsupportedOperationException
- for those types of methods of constructor that do not declare exceptions
-
getSpecifiedExceptions
default java.util.List<ResolvedType> getSpecifiedExceptions()
-
-