Package com.github.javaparser.ast.body
Class ConstructorDeclaration
java.lang.Object
com.github.javaparser.ast.Node
com.github.javaparser.ast.body.BodyDeclaration<T>
com.github.javaparser.ast.body.CallableDeclaration<ConstructorDeclaration>
com.github.javaparser.ast.body.ConstructorDeclaration
- All Implemented Interfaces:
NodeWithAbstractModifier<ConstructorDeclaration>
,NodeWithAccessModifiers<ConstructorDeclaration>
,NodeWithFinalModifier<ConstructorDeclaration>
,NodeWithPrivateModifier<ConstructorDeclaration>
,NodeWithProtectedModifier<ConstructorDeclaration>
,NodeWithPublicModifier<ConstructorDeclaration>
,NodeWithStaticModifier<ConstructorDeclaration>
,NodeWithStrictfpModifier<ConstructorDeclaration>
,NodeWithAnnotations<ConstructorDeclaration>
,NodeWithBlockStmt<ConstructorDeclaration>
,NodeWithDeclaration
,NodeWithJavadoc<ConstructorDeclaration>
,NodeWithModifiers<ConstructorDeclaration>
,NodeWithParameters<ConstructorDeclaration>
,NodeWithRange<Node>
,NodeWithSimpleName<ConstructorDeclaration>
,NodeWithThrownExceptions<ConstructorDeclaration>
,NodeWithTokenRange<Node>
,NodeWithTypeParameters<ConstructorDeclaration>
,Observable
,Visitable
,HasParentNode<Node>
,Resolvable<ResolvedConstructorDeclaration>
,Cloneable
public class ConstructorDeclaration
extends CallableDeclaration<ConstructorDeclaration>
implements NodeWithBlockStmt<ConstructorDeclaration>, NodeWithAccessModifiers<ConstructorDeclaration>, NodeWithJavadoc<ConstructorDeclaration>, NodeWithSimpleName<ConstructorDeclaration>, NodeWithParameters<ConstructorDeclaration>, NodeWithThrownExceptions<ConstructorDeclaration>, NodeWithTypeParameters<ConstructorDeclaration>, Resolvable<ResolvedConstructorDeclaration>
A constructor declaration:
class X { X() { } }
where X(){} is the constructor declaration.
All annotations preceding the name will be set on this object, not on the class.
JavaParser doesn't know if it they are applicable to the method or the class.
- Author:
- Julio Vilmar Gesser
-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.javaparser.ast.body.CallableDeclaration
CallableDeclaration.Signature
Nested classes/interfaces inherited from class com.github.javaparser.ast.Node
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal
-
Field Summary
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY
-
Constructor Summary
ConstructorDescriptionConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
ConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)
ConstructorDeclaration(NodeList<Modifier> modifiers, String name)
ConstructorDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)
This constructor is used by the parser and is considered private.ConstructorDeclaration(String name)
-
Method Summary
Modifier and TypeMethodDescription<R, A> R
accept(GenericVisitor<R,A> v, A arg)
Accept method for visitor support.<A> void
accept(VoidVisitor<A> v, A arg)
Accept method for visitor support.clone()
getBody()
getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)
The declaration returned has this schema:void
boolean
boolean
resolve()
Sets the bodysetModifiers(NodeList<Modifier> modifiers)
setName(SimpleName name)
setParameters(NodeList<Parameter> parameters)
setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
setTypeParameters(NodeList<TypeParameter> typeParameters)
Methods inherited from class com.github.javaparser.ast.body.CallableDeclaration
appendThrowsIfRequested, asCallableDeclaration, getModifiers, getName, getParameters, getReceiverParameter, getSignature, getThrownExceptions, getTypeParameters, ifCallableDeclaration, isCallableDeclaration, isFixedArityMethod, isVariableArityMethod, remove, removeReceiverParameter, setReceiverParameter, toCallableDeclaration
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asClassOrInterfaceDeclaration, asCompactConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asMethodDeclaration, asRecordDeclaration, asTypeDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifClassOrInterfaceDeclaration, ifCompactConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifMethodDeclaration, ifRecordDeclaration, ifTypeDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isClassOrInterfaceDeclaration, isCompactConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isMethodDeclaration, isRecordDeclaration, isTypeDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toClassOrInterfaceDeclaration, toCompactConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toMethodDeclaration, toRecordDeclaration, toTypeDeclaration
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getDefaultPrinterConfiguration, getLineEndingStyle, getLineEndingStyleOrDefault, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getPrinter, getPrinter, getRange, getSymbolResolver, getTokenRange, hashCode, hasScope, isAncestorOf, isPhantom, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.github.javaparser.HasParentNode
findAncestor, findAncestor, findAncestor, hasParentNode, isDescendantOf
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAbstractModifier
isAbstract, setAbstract
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnit
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt
createBody
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithDeclaration
getDeclarationAsString, getDeclarationAsString
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithFinalModifier
isFinal, setFinal
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocComment
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getAccessSpecifier, getModifiers, hasModifier, removeModifier, setModifier, setModifiers
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithParameters
addAndGetParameter, addAndGetParameter, addAndGetParameter, addAndGetParameter, addParameter, addParameter, addParameter, addParameter, getParameter, getParameterByName, getParameterByType, getParameterByType, getParameters, hasParametersOfType, hasParametersOfType, setParameter, tryAddImportToParentCompilationUnit
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier
isPrivate, setPrivate
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier
isProtected, setProtected
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier
isPublic, setPublic
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRange
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getName, getNameAsExpression, getNameAsString, setName
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier
isStatic, setStatic
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier
isStrictfp, setStrictfp
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions
addThrownException, addThrownException, getThrownException, getThrownExceptions, isThrown, isThrown, tryAddImportToParentCompilationUnit
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters
addTypeParameter, addTypeParameter, getTypeParameter, getTypeParameters, isGeneric, setTypeParameter
-
Constructor Details
-
ConstructorDeclaration
public ConstructorDeclaration() -
ConstructorDeclaration
-
ConstructorDeclaration
-
ConstructorDeclaration
public ConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body) -
ConstructorDeclaration
public ConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter) -
ConstructorDeclaration
public ConstructorDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)This constructor is used by the parser and is considered private.
-
-
Method Details
-
accept
Description copied from interface:Visitable
Accept method for visitor support.- Specified by:
accept
in interfaceVisitable
- Type Parameters:
R
- the type of the return value of the visitorA
- the type the user argument passed to the visitor- Parameters:
v
- the visitor implementationarg
- the argument passed to the visitor (of type A)- Returns:
- the result of the visit (of type R)
-
accept
Description copied from interface:Visitable
Accept method for visitor support. -
getBody
- Specified by:
getBody
in interfaceNodeWithBlockStmt<ConstructorDeclaration>
-
setBody
Sets the body- Specified by:
setBody
in interfaceNodeWithBlockStmt<ConstructorDeclaration>
- Parameters:
body
- the body, can not be null- Returns:
- this, the ConstructorDeclaration
-
setModifiers
- Specified by:
setModifiers
in interfaceNodeWithModifiers<ConstructorDeclaration>
- Overrides:
setModifiers
in classCallableDeclaration<ConstructorDeclaration>
-
setName
- Specified by:
setName
in interfaceNodeWithSimpleName<ConstructorDeclaration>
- Overrides:
setName
in classCallableDeclaration<ConstructorDeclaration>
-
setParameters
- Specified by:
setParameters
in interfaceNodeWithParameters<ConstructorDeclaration>
- Overrides:
setParameters
in classCallableDeclaration<ConstructorDeclaration>
-
setThrownExceptions
- Specified by:
setThrownExceptions
in interfaceNodeWithThrownExceptions<ConstructorDeclaration>
- Overrides:
setThrownExceptions
in classCallableDeclaration<ConstructorDeclaration>
-
setTypeParameters
- Specified by:
setTypeParameters
in interfaceNodeWithTypeParameters<ConstructorDeclaration>
- Overrides:
setTypeParameters
in classCallableDeclaration<ConstructorDeclaration>
-
getDeclarationAsString
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)The declaration returned has this schema:[accessSpecifier] className ([paramType [paramName]]) [throws exceptionsList]
- Specified by:
getDeclarationAsString
in interfaceNodeWithDeclaration
- Parameters:
includingModifiers
- flag to include the modifiers (if present) in the string producedincludingThrows
- flag to include the throws clause (if present) in the string producedincludingParameterName
- flag to include the parameter name (while the parameter type is always included) in the string produced- Returns:
- String representation of declaration based on parameter flags
-
toDescriptor
-
clone
- Overrides:
clone
in classCallableDeclaration<ConstructorDeclaration>
-
getMetaModel
- Overrides:
getMetaModel
in classCallableDeclaration<ConstructorDeclaration>
- Returns:
- get JavaParser specific node introspection information.
-
replace
- Overrides:
replace
in classCallableDeclaration<ConstructorDeclaration>
-
isConstructorDeclaration
public boolean isConstructorDeclaration()- Overrides:
isConstructorDeclaration
in classBodyDeclaration<ConstructorDeclaration>
-
asConstructorDeclaration
- Overrides:
asConstructorDeclaration
in classBodyDeclaration<ConstructorDeclaration>
-
ifConstructorDeclaration
- Overrides:
ifConstructorDeclaration
in classBodyDeclaration<ConstructorDeclaration>
-
resolve
- Specified by:
resolve
in interfaceResolvable<ResolvedConstructorDeclaration>
-
toConstructorDeclaration
- Overrides:
toConstructorDeclaration
in classBodyDeclaration<ConstructorDeclaration>
-