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.SignatureNested 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
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> Raccept(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:voidbooleanbooleanbooleanresolve()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, removeReceiverParameter, setReceiverParameter, toCallableDeclarationMethods 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, toTypeDeclarationMethods 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, walkMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.github.javaparser.HasParentNode
findAncestor, findAncestor, hasParentNode, isDescendantOfMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAbstractModifier
isAbstract, setAbstractMethods 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, tryAddImportToParentCompilationUnitMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt
createBodyMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithDeclaration
getDeclarationAsString, getDeclarationAsStringMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithFinalModifier
isFinal, setFinalMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocCommentMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getAccessSpecifier, getModifiers, hasModifier, removeModifier, setModifier, setModifiersMethods 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, tryAddImportToParentCompilationUnitMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier
isPrivate, setPrivateMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier
isProtected, setProtectedMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier
isPublic, setPublicMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRangeMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getName, getNameAsExpression, getNameAsString, setNameMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier
isStatic, setStaticMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier
isStrictfp, setStrictfpMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions
addThrownException, addThrownException, getThrownException, getThrownExceptions, isThrown, isThrown, tryAddImportToParentCompilationUnitMethods 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: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
-
remove
- Overrides:
removein classCallableDeclaration<ConstructorDeclaration>
-
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>
-