Class JavaParserConstructorDeclaration<N extends ResolvedReferenceTypeDeclaration>
- java.lang.Object
-
- com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserConstructorDeclaration<N>
-
- All Implemented Interfaces:
AssociableToAST,HasAccessSpecifier,ResolvedConstructorDeclaration,ResolvedDeclaration,ResolvedMethodLikeDeclaration,ResolvedTypeParametrizable
public class JavaParserConstructorDeclaration<N extends ResolvedReferenceTypeDeclaration> extends java.lang.Object implements ResolvedConstructorDeclaration
-
-
Field Summary
Fields Modifier and Type Field Description private NdeclaringTypeprivate TypeSolvertypeSolverprivate ConstructorDeclarationwrappedNode
-
Constructor Summary
Constructors Constructor Description JavaParserConstructorDeclaration(N declaringType, ConstructorDeclaration wrappedNode, TypeSolver typeSolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessSpecifieraccessSpecifier()The access specifier of this element.NdeclaringType()A constructor can be declared in a class or an enum.java.lang.StringgetName()Should return the name or return null if the name is not available.intgetNumberOfParams()Number of params.intgetNumberOfSpecifiedExceptions()Number of exceptions listed in the throws clause.ResolvedParameterDeclarationgetParam(int i)Get the ParameterDeclaration at the corresponding position or throw IllegalArgumentException.ResolvedTypegetSpecifiedException(int index)Type of the corresponding entry in the throws clause.java.util.List<ResolvedTypeParameterDeclaration>getTypeParameters()The list of type parameters defined on this element.ConstructorDeclarationgetWrappedNode()Returns the JavaParser node associated with this JavaParserConstructorDeclaration.java.util.Optional<Node>toAst()If the declaration is associated to an AST node return it, otherwise it return empty.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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, asType, asTypePattern, hasName, isEnumConstant, isField, isMethod, isParameter, isType, isTypePattern, isVariable
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedMethodLikeDeclaration
findTypeParameter, formalParameterTypes, getClassName, getLastParam, getPackageName, getQualifiedName, getQualifiedSignature, getSignature, getSpecifiedExceptions, hasVariadicParameter
-
Methods inherited from interface com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable
isGeneric
-
-
-
-
Field Detail
-
declaringType
private N extends ResolvedReferenceTypeDeclaration declaringType
-
wrappedNode
private ConstructorDeclaration wrappedNode
-
typeSolver
private TypeSolver typeSolver
-
-
Constructor Detail
-
JavaParserConstructorDeclaration
JavaParserConstructorDeclaration(N declaringType, ConstructorDeclaration wrappedNode, TypeSolver typeSolver)
-
-
Method Detail
-
declaringType
public N declaringType()
Description copied from interface:ResolvedConstructorDeclarationA constructor can be declared in a class or an enum.- Specified by:
declaringTypein interfaceResolvedConstructorDeclaration- Specified by:
declaringTypein interfaceResolvedMethodLikeDeclaration
-
getNumberOfParams
public int getNumberOfParams()
Description copied from interface:ResolvedMethodLikeDeclarationNumber of params.- Specified by:
getNumberOfParamsin interfaceResolvedMethodLikeDeclaration
-
getParam
public ResolvedParameterDeclaration getParam(int i)
Description copied from interface:ResolvedMethodLikeDeclarationGet the ParameterDeclaration at the corresponding position or throw IllegalArgumentException.- Specified by:
getParamin interfaceResolvedMethodLikeDeclaration
-
getName
public java.lang.String getName()
Description copied from interface:ResolvedDeclarationShould return the name or return null if the name is not available.- Specified by:
getNamein interfaceResolvedDeclaration
-
getWrappedNode
public ConstructorDeclaration getWrappedNode()
Returns the JavaParser node associated with this JavaParserConstructorDeclaration.- Returns:
- A visitable JavaParser node wrapped by this object.
-
accessSpecifier
public AccessSpecifier accessSpecifier()
Description copied from interface:HasAccessSpecifierThe access specifier of this element.- Specified by:
accessSpecifierin interfaceHasAccessSpecifier
-
getTypeParameters
public java.util.List<ResolvedTypeParameterDeclaration> getTypeParameters()
Description copied from interface:ResolvedTypeParametrizableThe list of type parameters defined on this element.- Specified by:
getTypeParametersin interfaceResolvedTypeParametrizable
-
getNumberOfSpecifiedExceptions
public int getNumberOfSpecifiedExceptions()
Description copied from interface:ResolvedMethodLikeDeclarationNumber of exceptions listed in the throws clause.- Specified by:
getNumberOfSpecifiedExceptionsin interfaceResolvedMethodLikeDeclaration
-
getSpecifiedException
public ResolvedType getSpecifiedException(int index)
Description copied from interface:ResolvedMethodLikeDeclarationType of the corresponding entry in the throws clause.- Specified by:
getSpecifiedExceptionin interfaceResolvedMethodLikeDeclaration
-
toAst
public java.util.Optional<Node> 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
-
-