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>
,Cloneable
public final class ConstructorDeclaration extends CallableDeclaration<ConstructorDeclaration> implements NodeWithBlockStmt<ConstructorDeclaration>, NodeWithAccessModifiers<ConstructorDeclaration>, NodeWithJavadoc<ConstructorDeclaration>, NodeWithDeclaration, NodeWithSimpleName<ConstructorDeclaration>, NodeWithParameters<ConstructorDeclaration>, NodeWithThrownExceptions<ConstructorDeclaration>, NodeWithTypeParameters<ConstructorDeclaration>
A constructor declaration:class X { X() { } }
where X(){} is the constructor declaration.- 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.ObserverRegistrationMode, Node.Parsedness
-
-
Field Summary
-
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
-
-
Constructor Summary
Constructors Constructor Description ConstructorDeclaration()
ConstructorDeclaration(TokenRange tokenRange, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
This constructor is used by the parser and is considered private.ConstructorDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
ConstructorDeclaration(EnumSet<Modifier> modifiers, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,A>
Raccept(GenericVisitor<R,A> v, A arg)
Accept method for visitor support.<A> void
accept(VoidVisitor<A> v, A arg)
Accept method for visitor support.ConstructorDeclaration
clone()
BlockStmt
getBody()
String
getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)
The declaration returned has this schema:ConstructorDeclarationMetaModel
getMetaModel()
List<NodeList<?>>
getNodeLists()
The list of NodeLists owned by this node.boolean
remove(Node node)
boolean
replace(Node node, Node replacementNode)
ConstructorDeclaration
setBody(BlockStmt body)
Sets the bodyConstructorDeclaration
setModifiers(EnumSet<Modifier> modifiers)
ConstructorDeclaration
setName(SimpleName name)
ConstructorDeclaration
setParameters(NodeList<Parameter> parameters)
ConstructorDeclaration
setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
ConstructorDeclaration
setTypeParameters(NodeList<TypeParameter> typeParameters)
-
Methods inherited from class com.github.javaparser.ast.body.CallableDeclaration
appendThrowsIfRequested, getDeclarationAsString, getDeclarationAsString, getModifiers, getName, getParameters, getSignature, getThrownExceptions, getTypeParameters
-
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
getAnnotations, setAnnotations
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, customInitialization, equals, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.HasParentNode
getAncestorOfType
-
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, 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
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getModifiers, removeModifier, setModifier
-
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, isPositionedAfter, isPositionedBefore
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getName, 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, getTypeParameter, getTypeParameters, isGeneric, setTypeParameter
-
-
-
-
Constructor Detail
-
ConstructorDeclaration
public ConstructorDeclaration()
-
ConstructorDeclaration
public ConstructorDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
-
ConstructorDeclaration
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator") public ConstructorDeclaration(TokenRange tokenRange, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
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: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
public <A> void accept(VoidVisitor<A> v, A arg)
Description copied from interface:Visitable
Accept method for visitor support.
-
getBody
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public BlockStmt getBody()
- Specified by:
getBody
in interfaceNodeWithBlockStmt<ConstructorDeclaration>
-
setBody
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public ConstructorDeclaration setBody(BlockStmt body)
Sets the body- Specified by:
setBody
in interfaceNodeWithBlockStmt<ConstructorDeclaration>
- Parameters:
body
- the body, can not be null- Returns:
- this, the ConstructorDeclaration
-
setModifiers
public ConstructorDeclaration setModifiers(EnumSet<Modifier> modifiers)
- Specified by:
setModifiers
in interfaceNodeWithModifiers<ConstructorDeclaration>
- Overrides:
setModifiers
in classCallableDeclaration<ConstructorDeclaration>
-
setName
public ConstructorDeclaration setName(SimpleName name)
- Specified by:
setName
in interfaceNodeWithSimpleName<ConstructorDeclaration>
- Overrides:
setName
in classCallableDeclaration<ConstructorDeclaration>
-
setParameters
public ConstructorDeclaration setParameters(NodeList<Parameter> parameters)
- Specified by:
setParameters
in interfaceNodeWithParameters<ConstructorDeclaration>
- Overrides:
setParameters
in classCallableDeclaration<ConstructorDeclaration>
-
setThrownExceptions
public ConstructorDeclaration setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
- Specified by:
setThrownExceptions
in interfaceNodeWithThrownExceptions<ConstructorDeclaration>
- Overrides:
setThrownExceptions
in classCallableDeclaration<ConstructorDeclaration>
-
setTypeParameters
public ConstructorDeclaration setTypeParameters(NodeList<TypeParameter> typeParameters)
- 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
- Specified by:
getDeclarationAsString
in 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
-
getNodeLists
@Generated("com.github.javaparser.generator.core.node.GetNodeListsGenerator") public List<NodeList<?>> getNodeLists()
Description copied from class:Node
The list of NodeLists owned by this node.- Overrides:
getNodeLists
in classCallableDeclaration<ConstructorDeclaration>
-
remove
@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator") public boolean remove(Node node)
- Overrides:
remove
in classCallableDeclaration<ConstructorDeclaration>
-
clone
@Generated("com.github.javaparser.generator.core.node.CloneGenerator") public ConstructorDeclaration clone()
- Overrides:
clone
in classCallableDeclaration<ConstructorDeclaration>
-
getMetaModel
@Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator") public ConstructorDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModel
in classCallableDeclaration<ConstructorDeclaration>
- Returns:
- get JavaParser specific node introspection information.
-
replace
@Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator") public boolean replace(Node node, Node replacementNode)
- Overrides:
replace
in classCallableDeclaration<ConstructorDeclaration>
-
-