Top Description Fields Constructors Methods
com.github.javaparser.ast.body

public Class ConstructorDeclaration

extends CallableDeclaration<ConstructorDeclaration>
implements NodeWithBlockStmt<ConstructorDeclaration>, NodeWithAccessModifiers<ConstructorDeclaration>, NodeWithJavadoc<ConstructorDeclaration>, NodeWithSimpleName<ConstructorDeclaration>, NodeWithParameters<ConstructorDeclaration>, NodeWithThrownExceptions<ConstructorDeclaration>, NodeWithTypeParameters<ConstructorDeclaration>, Resolvable<ResolvedConstructorDeclaration>
Class Inheritance
All Implemented Interfaces
com.github.javaparser.resolution.Resolvable, com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters, com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions, com.github.javaparser.ast.nodeTypes.NodeWithParameters, com.github.javaparser.ast.nodeTypes.NodeWithSimpleName, com.github.javaparser.ast.nodeTypes.NodeWithJavadoc, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAccessModifiers, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier, com.github.javaparser.ast.nodeTypes.NodeWithModifiers, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier, com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt
Imports
com.github.javaparser.ast.*, .Node, .Generated, com.github.javaparser.ast.expr.AnnotationExpr, .SimpleName, com.github.javaparser.ast.nodeTypes.*, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAccessModifiers, com.github.javaparser.ast.observer.ObservableProperty, com.github.javaparser.ast.stmt.BlockStmt, com.github.javaparser.ast.type.ReferenceType, .TypeParameter, com.github.javaparser.ast.visitor.CloneVisitor, .GenericVisitor, .VoidVisitor, com.github.javaparser.metamodel.ConstructorDeclarationMetaModel, .JavaParserMetaModel, com.github.javaparser.TokenRange, com.github.javaparser.resolution.Resolvable, com.github.javaparser.resolution.declarations.ResolvedConstructorDeclaration, java.util.Optional, java.util.function.Consumer

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

Field Summary

Modifier and TypeField and Description
private BlockStmt

Constructor Summary

AccessConstructor and Description
public
public
public
public
ConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)

public
ConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)

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 Summary

Modifier and TypeMethod and Description
public <R, A> R
accept(final GenericVisitor<R, A>
the visitor implementation
v
,
final A
the argument passed to the visitor (of type A)
arg
)

Implements com.github.javaparser.ast.visitor.Visitable.accept.

Accept method for visitor support.
public <A> void
accept(final VoidVisitor<A>
the visitor implementation
v
,
final A
any value relevant for the visitor (of type A)
arg
)

Implements com.github.javaparser.ast.visitor.Visitable.accept.

Accept method for visitor support.
public ConstructorDeclaration
public ConstructorDeclaration
clone()

Overrides com.github.javaparser.ast.body.CallableDeclaration.clone.

Creates and returns a copy of this object.
public BlockStmt
public String
getDeclarationAsString(boolean
flag to include the modifiers (if present) in the string produced
includingModifiers
,
boolean
flag to include the throws clause (if present) in the string produced
includingThrows
,
boolean
flag to include the parameter name (while the parameter type is always included) in the string produced
includingParameterName
)

Implements com.github.javaparser.ast.nodeTypes.NodeWithDeclaration.getDeclarationAsString.

The declaration returned has this schema:

[accessSpecifier] className ([paramType [paramName]]) [throws exceptionsList]

public ConstructorDeclarationMetaModel
public void
public boolean
public boolean
public boolean
public ResolvedConstructorDeclaration
public ConstructorDeclaration

Returns:

this, the ConstructorDeclaration
setBody
(final BlockStmt
the body, can not be null
body
)

Implements com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt.setBody.

Sets the body
public ConstructorDeclaration
public ConstructorDeclaration
public ConstructorDeclaration
public ConstructorDeclaration
public ConstructorDeclaration
public Optional<ConstructorDeclaration>
Inherited from com.github.javaparser.ast.body.CallableDeclaration:
appendThrowsIfRequestedasCallableDeclarationgetModifiersgetNamegetParametersgetReceiverParametergetSignaturegetThrownExceptionsgetTypeParametersifCallableDeclarationisCallableDeclarationremoveReceiverParametersetReceiverParametertoCallableDeclaration

Field Detail

bodyback to summary
private BlockStmt body

Constructor Detail

ConstructorDeclarationback to summary
public ConstructorDeclaration()
ConstructorDeclarationback to summary
public ConstructorDeclaration(String name)
ConstructorDeclarationback to summary
public ConstructorDeclaration(NodeList<Modifier> modifiers, String name)
ConstructorDeclarationback to summary
public ConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
ConstructorDeclarationback to summary
public ConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)
Annotations
@AllFieldsConstructor
ConstructorDeclarationback to summary
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.

Annotations
@Generated:com.github.javaparser.generator.core.node.MainConstructorGenerator

Method Detail

acceptback to summary
public <R, A> R accept(final GenericVisitor<R, A> v, final A arg)

Implements com.github.javaparser.ast.visitor.Visitable.accept.

Doc from com.github.javaparser.ast.visitor.Visitable.accept.

Accept method for visitor support.

Parameters
<R>
the type of the return value of the visitor
<A>
the type the user argument passed to the visitor
v:GenericVisitor<R, A>

the visitor implementation

arg:A

the argument passed to the visitor (of type A)

Returns:R

the result of the visit (of type R)

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.AcceptGenerator
acceptback to summary
public <A> void accept(final VoidVisitor<A> v, final A arg)

Implements com.github.javaparser.ast.visitor.Visitable.accept.

Doc from com.github.javaparser.ast.visitor.Visitable.accept.

Accept method for visitor support.

Parameters
<A>
the type the argument passed for the visitor
v:VoidVisitor<A>

the visitor implementation

arg:A

any value relevant for the visitor (of type A)

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.AcceptGenerator
asConstructorDeclarationback to summary
public ConstructorDeclaration asConstructorDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.asConstructorDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
cloneback to summary
public ConstructorDeclaration clone()

Overrides com.github.javaparser.ast.body.CallableDeclaration.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:ConstructorDeclaration

a clone of this instance.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.CloneGenerator
getBodyback to summary
public BlockStmt getBody()

Implements com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt.getBody.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
getDeclarationAsStringback to summary
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)

Implements com.github.javaparser.ast.nodeTypes.NodeWithDeclaration.getDeclarationAsString.

The declaration returned has this schema:

[accessSpecifier] className ([paramType [paramName]]) [throws exceptionsList]

Parameters
includingModifiers:boolean

Doc from com.github.javaparser.ast.nodeTypes.NodeWithDeclaration.getDeclarationAsString.

flag to include the modifiers (if present) in the string produced

includingThrows:boolean

Doc from com.github.javaparser.ast.nodeTypes.NodeWithDeclaration.getDeclarationAsString.

flag to include the throws clause (if present) in the string produced

includingParameterName:boolean

Doc from com.github.javaparser.ast.nodeTypes.NodeWithDeclaration.getDeclarationAsString.

flag to include the parameter name (while the parameter type is always included) in the string produced

Returns:String

Doc from com.github.javaparser.ast.nodeTypes.NodeWithDeclaration.getDeclarationAsString.

String representation of declaration based on parameter flags

Annotations
@Override
getMetaModelback to summary
public ConstructorDeclarationMetaModel getMetaModel()

Overrides com.github.javaparser.ast.body.CallableDeclaration.getMetaModel.

Returns:ConstructorDeclarationMetaModel

Doc from com.github.javaparser.ast.Node.getMetaModel.

get JavaParser specific node introspection information.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.GetMetaModelGenerator
ifConstructorDeclarationback to summary
public void ifConstructorDeclaration(Consumer<ConstructorDeclaration> action)

Overrides com.github.javaparser.ast.body.BodyDeclaration.ifConstructorDeclaration.

Annotations
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
isConstructorDeclarationback to summary
public boolean isConstructorDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.isConstructorDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
removeback to summary
public boolean remove(Node node)

Overrides com.github.javaparser.ast.body.CallableDeclaration.remove.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.RemoveMethodGenerator
replaceback to summary
public boolean replace(Node node, Node replacementNode)

Overrides com.github.javaparser.ast.body.CallableDeclaration.replace.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.ReplaceMethodGenerator
resolveback to summary
public ResolvedConstructorDeclaration resolve()

Implements com.github.javaparser.resolution.Resolvable.resolve.

Annotations
@Override
setBodyback to summary
public ConstructorDeclaration setBody(final BlockStmt body)

Implements com.github.javaparser.ast.nodeTypes.NodeWithBlockStmt.setBody.

Sets the body

Parameters
body:BlockStmt

the body, can not be null

Returns:ConstructorDeclaration

this, the ConstructorDeclaration

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
setModifiersback to summary
public ConstructorDeclaration setModifiers(final NodeList<Modifier> modifiers)

Overrides com.github.javaparser.ast.body.CallableDeclaration.setModifiers.

Implements com.github.javaparser.ast.nodeTypes.NodeWithModifiers.setModifiers.

Annotations
@Override
setNameback to summary
public ConstructorDeclaration setName(final SimpleName name)

Overrides com.github.javaparser.ast.body.CallableDeclaration.setName.

Implements com.github.javaparser.ast.nodeTypes.NodeWithSimpleName.setName.

Annotations
@Override
setParametersback to summary
public ConstructorDeclaration setParameters(final NodeList<Parameter> parameters)

Overrides com.github.javaparser.ast.body.CallableDeclaration.setParameters.

Implements com.github.javaparser.ast.nodeTypes.NodeWithParameters.setParameters.

Annotations
@Override
setThrownExceptionsback to summary
public ConstructorDeclaration setThrownExceptions(final NodeList<ReferenceType> thrownExceptions)

Overrides com.github.javaparser.ast.body.CallableDeclaration.setThrownExceptions.

Implements com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions.setThrownExceptions.

Annotations
@Override
setTypeParametersback to summary
public ConstructorDeclaration setTypeParameters(final NodeList<TypeParameter> typeParameters)

Overrides com.github.javaparser.ast.body.CallableDeclaration.setTypeParameters.

Implements com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters.setTypeParameters.

Annotations
@Override
toConstructorDeclarationback to summary
public Optional<ConstructorDeclaration> toConstructorDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.toConstructorDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator