Class ConstructorDeclaration
java.lang.Object
com.github.javaparser.ast.Node
com.github.javaparser.ast.body.BodyDeclaration<ConstructorDeclaration>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class CallableDeclaration
CallableDeclaration.SignatureNested classes/interfaces inherited from class Node
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal -
Field Summary
FieldsFields inherited from class Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY -
Constructor Summary
ConstructorsConstructorDescriptionConstructorDeclaration(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> voidaccept(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:voidbooleanbooleanresolve()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 CallableDeclaration
appendThrowsIfRequested, asCallableDeclaration, getModifiers, getName, getParameters, getReceiverParameter, getSignature, getThrownExceptions, getTypeParameters, ifCallableDeclaration, isCallableDeclaration, isFixedArityMethod, isVariableArityMethod, remove, removeReceiverParameter, setReceiverParameter, toCallableDeclarationMethods inherited from class 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, toTypeDeclarationMethods inherited from class Node
addOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findByRange, findCompilationUnit, findData, 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, walkMethods inherited from interface HasParentNode
findAncestor, findAncestor, findAncestor, hasParentNode, isDescendantOfMethods inherited from interface NodeWithAbstractModifier
isAbstract, setAbstractMethods inherited from interface NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnitMethods inherited from interface NodeWithBlockStmt
createBodyMethods inherited from interface NodeWithDeclaration
getDeclarationAsString, getDeclarationAsStringMethods inherited from interface NodeWithFinalModifier
isFinal, setFinalMethods inherited from interface NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocCommentMethods inherited from interface NodeWithModifiers
addModifier, getAccessSpecifier, getModifiers, hasModifier, removeModifier, setModifier, setModifiersMethods inherited from interface NodeWithParameters
addAndGetParameter, addAndGetParameter, addAndGetParameter, addAndGetParameter, addParameter, addParameter, addParameter, addParameter, getParameter, getParameterByName, getParameterByType, getParameterByType, getParameters, hasParametersOfType, hasParametersOfType, setParameter, tryAddImportToParentCompilationUnitMethods inherited from interface NodeWithPrivateModifier
isPrivate, setPrivateMethods inherited from interface NodeWithProtectedModifier
isProtected, setProtectedMethods inherited from interface NodeWithPublicModifier
isPublic, setPublicMethods inherited from interface NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRangeMethods inherited from interface NodeWithSimpleName
getName, getNameAsExpression, getNameAsString, setNameMethods inherited from interface NodeWithStaticModifier
isStatic, setStaticMethods inherited from interface NodeWithStrictfpModifier
isStrictfp, setStrictfpMethods inherited from interface NodeWithThrownExceptions
addThrownException, addThrownException, getThrownException, getThrownExceptions, isThrown, isThrown, tryAddImportToParentCompilationUnitMethods inherited from interface NodeWithTypeParameters
addTypeParameter, addTypeParameter, getTypeParameter, getTypeParameters, isGeneric, setTypeParameter
-
Field Details
-
body
-
-
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:VisitableAccept method for visitor support.- Specified by:
acceptin 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:VisitableAccept method for visitor support. -
getBody
- Specified by:
getBodyin interfaceNodeWithBlockStmt<ConstructorDeclaration>
-
setBody
Sets the body- Specified by:
setBodyin interfaceNodeWithBlockStmt<ConstructorDeclaration>- Parameters:
body- the body, can not be null- Returns:
- this, the ConstructorDeclaration
-
setModifiers
- Specified by:
setModifiersin interfaceNodeWithModifiers<ConstructorDeclaration>- Overrides:
setModifiersin classCallableDeclaration<ConstructorDeclaration>
-
setName
- Specified by:
setNamein interfaceNodeWithSimpleName<ConstructorDeclaration>- Overrides:
setNamein classCallableDeclaration<ConstructorDeclaration>
-
setParameters
- Specified by:
setParametersin interfaceNodeWithParameters<ConstructorDeclaration>- Overrides:
setParametersin classCallableDeclaration<ConstructorDeclaration>
-
setThrownExceptions
- Specified by:
setThrownExceptionsin interfaceNodeWithThrownExceptions<ConstructorDeclaration>- Overrides:
setThrownExceptionsin classCallableDeclaration<ConstructorDeclaration>
-
setTypeParameters
- Specified by:
setTypeParametersin interfaceNodeWithTypeParameters<ConstructorDeclaration>- Overrides:
setTypeParametersin 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:
getDeclarationAsStringin 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:
clonein classCallableDeclaration<ConstructorDeclaration>
-
getMetaModel
- Overrides:
getMetaModelin classCallableDeclaration<ConstructorDeclaration>- Returns:
- get JavaParser specific node introspection information.
-
replace
- Overrides:
replacein classCallableDeclaration<ConstructorDeclaration>
-
isConstructorDeclaration
public boolean isConstructorDeclaration()- Overrides:
isConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-
asConstructorDeclaration
- Overrides:
asConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-
ifConstructorDeclaration
- Overrides:
ifConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-
resolve
- Specified by:
resolvein interfaceResolvable<ResolvedConstructorDeclaration>
-
toConstructorDeclaration
- Overrides:
toConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-