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, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration, SYMBOL_RESOLVER_KEY
-
-
Constructor Summary
-
Method Summary
-
Methods inherited from class com.github.javaparser.ast.body.CallableDeclaration
appendThrowsIfRequested, asCallableDeclaration, getDeclarationAsString, getDeclarationAsString, getModifiers, getName, getParameters, getReceiverParameter, getSignature, getThrownExceptions, getTypeParameters, ifCallableDeclaration, isCallableDeclaration, removeReceiverParameter, setReceiverParameter, toCallableDeclaration
-
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asClassOrInterfaceDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asMethodDeclaration, asTypeDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifClassOrInterfaceDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifMethodDeclaration, ifTypeDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isClassOrInterfaceDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isMethodDeclaration, isTypeDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toClassOrInterfaceDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toMethodDeclaration, toTypeDeclaration
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, customInitialization, equals, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getSymbolResolver, getTokenRange, hashCode, 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
-
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.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, getBegin, getEnd
-
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 Detail
-
ConstructorDeclaration
public ConstructorDeclaration()
-
ConstructorDeclaration
public ConstructorDeclaration(String name)
-
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 Detail
-
accept
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
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
public <A> void accept(VoidVisitor<A> v, A arg)
Description copied from interface:VisitableAccept method for visitor support.
-
getBody
public BlockStmt getBody()
- Specified by:
getBodyin interfaceNodeWithBlockStmt<ConstructorDeclaration>
-
setBody
public ConstructorDeclaration setBody(BlockStmt body)
Sets the body- Specified by:
setBodyin interfaceNodeWithBlockStmt<ConstructorDeclaration>- Parameters:
body- the body, can not be null- Returns:
- this, the ConstructorDeclaration
-
setModifiers
public ConstructorDeclaration setModifiers(NodeList<Modifier> modifiers)
- Specified by:
setModifiersin interfaceNodeWithModifiers<ConstructorDeclaration>- Overrides:
setModifiersin classCallableDeclaration<ConstructorDeclaration>
-
setName
public ConstructorDeclaration setName(SimpleName name)
- Specified by:
setNamein interfaceNodeWithSimpleName<ConstructorDeclaration>- Overrides:
setNamein classCallableDeclaration<ConstructorDeclaration>
-
setParameters
public ConstructorDeclaration setParameters(NodeList<Parameter> parameters)
- Specified by:
setParametersin interfaceNodeWithParameters<ConstructorDeclaration>- Overrides:
setParametersin classCallableDeclaration<ConstructorDeclaration>
-
setThrownExceptions
public ConstructorDeclaration setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
- Specified by:
setThrownExceptionsin interfaceNodeWithThrownExceptions<ConstructorDeclaration>- Overrides:
setThrownExceptionsin classCallableDeclaration<ConstructorDeclaration>
-
setTypeParameters
public ConstructorDeclaration setTypeParameters(NodeList<TypeParameter> typeParameters)
- 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- Specified by:
getDeclarationAsStringin classCallableDeclaration<ConstructorDeclaration>- 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
public boolean remove(Node node)
- Overrides:
removein classCallableDeclaration<ConstructorDeclaration>
-
clone
public ConstructorDeclaration clone()
- Overrides:
clonein classCallableDeclaration<ConstructorDeclaration>
-
getMetaModel
public ConstructorDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModelin classCallableDeclaration<ConstructorDeclaration>- Returns:
- get JavaParser specific node introspection information.
-
replace
public boolean replace(Node node, Node replacementNode)
- Overrides:
replacein classCallableDeclaration<ConstructorDeclaration>
-
isConstructorDeclaration
public boolean isConstructorDeclaration()
- Overrides:
isConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-
asConstructorDeclaration
public ConstructorDeclaration asConstructorDeclaration()
- Overrides:
asConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-
ifConstructorDeclaration
public void ifConstructorDeclaration(Consumer<ConstructorDeclaration> action)
- Overrides:
ifConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-
resolve
public ResolvedConstructorDeclaration resolve()
- Specified by:
resolvein interfaceResolvable<ResolvedConstructorDeclaration>
-
toConstructorDeclaration
public Optional<ConstructorDeclaration> toConstructorDeclaration()
- Overrides:
toConstructorDeclarationin classBodyDeclaration<ConstructorDeclaration>
-
-