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
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BlockStmtprivate SimpleNameprivate NodeList<ReferenceType> private NodeList<TypeParameter> Fields inherited from class Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY -
Constructor Summary
ConstructorsConstructorDescriptionCompactConstructorDeclaration(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> voidaccept(VoidVisitor<A> v, A arg) Accept method for visitor support.protected StringappendThrowsIfRequested(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()voidbooleanbooleanbooleanresolve()Sets the bodysetModifiers(NodeList<Modifier> modifiers) setName(SimpleName name) setThrownExceptions(NodeList<ReferenceType> thrownExceptions) setTypeParameters(NodeList<TypeParameter> typeParameters) Methods inherited from class 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, toTypeDeclarationMethods inherited from class 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, walkMethods inherited from interface HasParentNode
findAncestor, findAncestor, findAncestor, hasParentNode, isDescendantOfMethods inherited from interface NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnitMethods inherited from interface NodeWithBlockStmt
createBodyMethods inherited from interface NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocCommentMethods inherited from interface NodeWithModifiers
addModifier, getAccessSpecifier, hasModifier, removeModifier, setModifier, setModifiersMethods inherited from interface NodeWithPrivateModifier
isPrivate, setPrivateMethods inherited from interface NodeWithProtectedModifier
isProtected, setProtectedMethods inherited from interface NodeWithPublicModifier
isPublic, setPublicMethods inherited from interface NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRangeMethods inherited from interface NodeWithSimpleName
getNameAsExpression, getNameAsString, setNameMethods inherited from interface NodeWithThrownExceptions
addThrownException, addThrownException, getThrownException, isThrown, isThrown, tryAddImportToParentCompilationUnitMethods inherited from interface NodeWithTypeParameters
addTypeParameter, addTypeParameter, getTypeParameter, isGeneric, setTypeParameter
-
Field Details
-
modifiers
-
body
-
typeParameters
-
name
-
thrownExceptions
-
-
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: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
Description copied from interface:VisitableAccept method for visitor support. -
getBody
- Specified by:
getBodyin interfaceNodeWithBlockStmt<CompactConstructorDeclaration>
-
setBody
Sets the body- Specified by:
setBodyin interfaceNodeWithBlockStmt<CompactConstructorDeclaration>- Parameters:
body- the body, can not be null- Returns:
- this, the ConstructorDeclaration
-
getModifiers
Description copied from interface:NodeWithModifiersReturn the modifiers of this variable declaration. Warning: modifying the returned set will not trigger observers, you have to use setModifiers for that.- Specified by:
getModifiersin interfaceNodeWithModifiers<CompactConstructorDeclaration>- Returns:
- modifiers
- See Also:
-
setModifiers
- Specified by:
setModifiersin interfaceNodeWithModifiers<CompactConstructorDeclaration>
-
getName
- Specified by:
getNamein interfaceNodeWithSimpleName<CompactConstructorDeclaration>
-
setName
- Specified by:
setNamein interfaceNodeWithSimpleName<CompactConstructorDeclaration>
-
getThrownExceptions
- Specified by:
getThrownExceptionsin interfaceNodeWithThrownExceptions<CompactConstructorDeclaration>
-
setThrownExceptions
- Specified by:
setThrownExceptionsin interfaceNodeWithThrownExceptions<CompactConstructorDeclaration>
-
getTypeParameters
- Specified by:
getTypeParametersin interfaceNodeWithTypeParameters<CompactConstructorDeclaration>
-
setTypeParameters
- Specified by:
setTypeParametersin 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:
removein classBodyDeclaration<CompactConstructorDeclaration>
-
clone
- Overrides:
clonein classBodyDeclaration<CompactConstructorDeclaration>
-
getMetaModel
- Overrides:
getMetaModelin classBodyDeclaration<CompactConstructorDeclaration>- Returns:
- get JavaParser specific node introspection information.
-
replace
- Overrides:
replacein classBodyDeclaration<CompactConstructorDeclaration>
-
isCompactConstructorDeclaration
public boolean isCompactConstructorDeclaration()- Overrides:
isCompactConstructorDeclarationin classBodyDeclaration<CompactConstructorDeclaration>
-
asCompactConstructorDeclaration
- Overrides:
asCompactConstructorDeclarationin classBodyDeclaration<CompactConstructorDeclaration>
-
ifCompactConstructorDeclaration
- Overrides:
ifCompactConstructorDeclarationin classBodyDeclaration<CompactConstructorDeclaration>
-
resolve
- Specified by:
resolvein interfaceResolvable<ResolvedConstructorDeclaration>
-
toCompactConstructorDeclaration
- Overrides:
toCompactConstructorDeclarationin classBodyDeclaration<CompactConstructorDeclaration>
-