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{ } }
wherepublic 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
Constructors Constructor Description CompactConstructorDeclaration()
CompactConstructorDeclaration(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.CompactConstructorDeclaration(String name)
-
Method Summary
-
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, findByRange, findCompilationUnit, findData, 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 Detail
-
CompactConstructorDeclaration
public CompactConstructorDeclaration()
-
CompactConstructorDeclaration
public CompactConstructorDeclaration(String name)
-
CompactConstructorDeclaration
public CompactConstructorDeclaration(NodeList<Modifier> modifiers, String name)
-
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 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
public BlockStmt getBody()
- Specified by:
getBody
in interfaceNodeWithBlockStmt<CompactConstructorDeclaration>
-
setBody
public CompactConstructorDeclaration setBody(BlockStmt body)
Sets the body- Specified by:
setBody
in interfaceNodeWithBlockStmt<CompactConstructorDeclaration>
- Parameters:
body
- the body, can not be null- Returns:
- this, the ConstructorDeclaration
-
getModifiers
public NodeList<Modifier> 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
public CompactConstructorDeclaration setModifiers(NodeList<Modifier> modifiers)
- Specified by:
setModifiers
in interfaceNodeWithModifiers<CompactConstructorDeclaration>
-
getName
public SimpleName getName()
- Specified by:
getName
in interfaceNodeWithSimpleName<CompactConstructorDeclaration>
-
setName
public CompactConstructorDeclaration setName(SimpleName name)
- Specified by:
setName
in interfaceNodeWithSimpleName<CompactConstructorDeclaration>
-
getThrownExceptions
public NodeList<ReferenceType> getThrownExceptions()
- Specified by:
getThrownExceptions
in interfaceNodeWithThrownExceptions<CompactConstructorDeclaration>
-
setThrownExceptions
public CompactConstructorDeclaration setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
- Specified by:
setThrownExceptions
in interfaceNodeWithThrownExceptions<CompactConstructorDeclaration>
-
getTypeParameters
public NodeList<TypeParameter> getTypeParameters()
- Specified by:
getTypeParameters
in interfaceNodeWithTypeParameters<CompactConstructorDeclaration>
-
setTypeParameters
public CompactConstructorDeclaration setTypeParameters(NodeList<TypeParameter> typeParameters)
- 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
protected String appendThrowsIfRequested(boolean includingThrows)
-
remove
public boolean remove(Node node)
- Overrides:
remove
in classBodyDeclaration<CompactConstructorDeclaration>
-
clone
public CompactConstructorDeclaration clone()
- Overrides:
clone
in classBodyDeclaration<CompactConstructorDeclaration>
-
getMetaModel
public CompactConstructorDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModel
in classBodyDeclaration<CompactConstructorDeclaration>
- Returns:
- get JavaParser specific node introspection information.
-
replace
public boolean replace(Node node, Node replacementNode)
- Overrides:
replace
in classBodyDeclaration<CompactConstructorDeclaration>
-
isCompactConstructorDeclaration
public boolean isCompactConstructorDeclaration()
- Overrides:
isCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-
asCompactConstructorDeclaration
public CompactConstructorDeclaration asCompactConstructorDeclaration()
- Overrides:
asCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-
ifCompactConstructorDeclaration
public void ifCompactConstructorDeclaration(Consumer<CompactConstructorDeclaration> action)
- Overrides:
ifCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-
resolve
public ResolvedConstructorDeclaration resolve()
- Specified by:
resolve
in interfaceResolvable<ResolvedConstructorDeclaration>
-
toCompactConstructorDeclaration
public Optional<CompactConstructorDeclaration> toCompactConstructorDeclaration()
- Overrides:
toCompactConstructorDeclaration
in classBodyDeclaration<CompactConstructorDeclaration>
-
-