Package com.github.javaparser.ast.body
Class CompactConstructorDeclaration
java.lang.Object
com.github.javaparser.ast.Node
com.github.javaparser.ast.body.BodyDeclaration<CompactConstructorDeclaration>
com.github.javaparser.ast.body.CompactConstructorDeclaration
- All Implemented Interfaces:
NodeWithAccessModifiers<CompactConstructorDeclaration>
,NodeWithPrivateModifier<CompactConstructorDeclaration>
,NodeWithProtectedModifier<CompactConstructorDeclaration>
,NodeWithPublicModifier<CompactConstructorDeclaration>
,NodeWithAnnotations<CompactConstructorDeclaration>
,NodeWithBlockStmt<CompactConstructorDeclaration>
,NodeWithJavadoc<CompactConstructorDeclaration>
,NodeWithModifiers<CompactConstructorDeclaration>
,NodeWithRange<Node>
,NodeWithSimpleName<CompactConstructorDeclaration>
,NodeWithThrownExceptions<CompactConstructorDeclaration>
,NodeWithTokenRange<Node>
,NodeWithTypeParameters<CompactConstructorDeclaration>
,Observable
,Visitable
,HasParentNode<Node>
,Resolvable<ResolvedConstructorDeclaration>
,Cloneable
public class CompactConstructorDeclaration
extends BodyDeclaration<CompactConstructorDeclaration>
implements NodeWithBlockStmt<CompactConstructorDeclaration>, NodeWithAccessModifiers<CompactConstructorDeclaration>, NodeWithJavadoc<CompactConstructorDeclaration>, NodeWithSimpleName<CompactConstructorDeclaration>, NodeWithThrownExceptions<CompactConstructorDeclaration>, NodeWithTypeParameters<CompactConstructorDeclaration>, Resolvable<ResolvedConstructorDeclaration>
The record declaration's constructor
WARNING: This implementation is subject to change.Java 1.0 to 13
Not available.Java 14 (preview), Java 15 (2nd preview), Java 16
A record "compact" constructor declaration: class X(int a, int b) { public X{ } }
where public X{}
is the compact record constructor declaration.
Note that the record constructor is distinct from a "standard" constructor as it does not permit arguments/parameters.
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.
- Since:
- 3.22.0
- Author:
- Roger Howell
- See Also:
- JLS 8.10 - Record Classes, JLS 8.10.3 - Record Constructor Declarations
-
Nested Class Summary
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, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY
-
Constructor Summary
ConstructorDescriptionCompactConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
CompactConstructorDeclaration(NodeList<Modifier> modifiers, String name)
CompactConstructorDeclaration(TokenRange tokenRange, NodeList<AnnotationExpr> annotations, BlockStmt body)
This constructor is used by the parser and is considered private.CompactConstructorDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
This constructor is used by the parser and is considered private. -
Method Summary
Modifier and TypeMethodDescription<R, A> R
accept(GenericVisitor<R,A> v, A arg)
Accept method for visitor support.<A> void
accept(VoidVisitor<A> v, A arg)
Accept method for visitor support.protected String
appendThrowsIfRequested(boolean includingThrows)
clone()
getBody()
getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)
The declaration returned has this schema:Return the modifiers of this variable declaration.getName()
void
boolean
boolean
boolean
resolve()
Sets the bodysetModifiers(NodeList<Modifier> modifiers)
setName(SimpleName name)
setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
setTypeParameters(NodeList<TypeParameter> typeParameters)
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asCallableDeclaration, asClassOrInterfaceDeclaration, asConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asMethodDeclaration, asRecordDeclaration, asTypeDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifCallableDeclaration, ifClassOrInterfaceDeclaration, ifConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifMethodDeclaration, ifRecordDeclaration, ifTypeDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isCallableDeclaration, isClassOrInterfaceDeclaration, isConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isMethodDeclaration, isRecordDeclaration, isTypeDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toCallableDeclaration, toClassOrInterfaceDeclaration, toConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toMethodDeclaration, toRecordDeclaration, toTypeDeclaration
Methods 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, 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, findAncestor, hasParentNode, isDescendantOf
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.NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocComment
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getAccessSpecifier, hasModifier, removeModifier, setModifier, setModifiers
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, containsWithinRange, getBegin, getEnd, hasRange
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getNameAsExpression, getNameAsString, setName
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions
addThrownException, addThrownException, getThrownException, isThrown, isThrown, tryAddImportToParentCompilationUnit
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters
addTypeParameter, addTypeParameter, getTypeParameter, isGeneric, setTypeParameter
-
Constructor Details
-
CompactConstructorDeclaration
public CompactConstructorDeclaration() -
CompactConstructorDeclaration
-
CompactConstructorDeclaration
-
CompactConstructorDeclaration
public CompactConstructorDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<ReferenceType> thrownExceptions, BlockStmt body) -
CompactConstructorDeclaration
public CompactConstructorDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<ReferenceType> thrownExceptions, BlockStmt body)This constructor is used by the parser and is considered private. -
CompactConstructorDeclaration
public CompactConstructorDeclaration(TokenRange tokenRange, NodeList<AnnotationExpr> annotations, BlockStmt body)This constructor is used by the parser and is considered private.
-
-
Method Details
-
accept
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
Description copied from interface:Visitable
Accept method for visitor support. -
getBody
- Specified by:
getBody
in interfaceNodeWithBlockStmt<CompactConstructorDeclaration>
-
setBody
Sets the body- Specified by:
setBody
in interfaceNodeWithBlockStmt<CompactConstructorDeclaration>
- Parameters:
body
- the body, can not be null- Returns:
- this, the ConstructorDeclaration
-
getModifiers
Description copied from interface:NodeWithModifiers
Return the modifiers of this variable declaration. Warning: modifying the returned set will not trigger observers, you have to use setModifiers for that.- Specified by:
getModifiers
in interfaceNodeWithModifiers<CompactConstructorDeclaration>
- Returns:
- modifiers
- See Also:
Modifier
-
setModifiers
- Specified by:
setModifiers
in interfaceNodeWithModifiers<CompactConstructorDeclaration>
-
getName
- Specified by:
getName
in interfaceNodeWithSimpleName<CompactConstructorDeclaration>
-
setName
- Specified by:
setName
in interfaceNodeWithSimpleName<CompactConstructorDeclaration>
-
getThrownExceptions
- Specified by:
getThrownExceptions
in interfaceNodeWithThrownExceptions<CompactConstructorDeclaration>
-
setThrownExceptions
- Specified by:
setThrownExceptions
in interfaceNodeWithThrownExceptions<CompactConstructorDeclaration>
-
getTypeParameters
- Specified by:
getTypeParameters
in interfaceNodeWithTypeParameters<CompactConstructorDeclaration>
-
setTypeParameters
- Specified by:
setTypeParameters
in interfaceNodeWithTypeParameters<CompactConstructorDeclaration>
-
getDeclarationAsString
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)The declaration returned has this schema:[accessSpecifier] className [throws exceptionsList]
-
appendThrowsIfRequested
-
remove
- Overrides:
remove
in classBodyDeclaration<CompactConstructorDeclaration>
-
clone
- Overrides:
clone
in classBodyDeclaration<CompactConstructorDeclaration>
-
getMetaModel
- Overrides:
getMetaModel
in classBodyDeclaration<CompactConstructorDeclaration>
- Returns:
- get JavaParser specific node introspection information.
-
replace
- Overrides:
replace
in classBodyDeclaration<CompactConstructorDeclaration>
-
isCompactConstructorDeclaration
public boolean isCompactConstructorDeclaration()- Overrides:
isCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-
asCompactConstructorDeclaration
- Overrides:
asCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-
ifCompactConstructorDeclaration
- Overrides:
ifCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-
resolve
- Specified by:
resolve
in interfaceResolvable<ResolvedConstructorDeclaration>
-
toCompactConstructorDeclaration
- Overrides:
toCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-