public class SwitchStmt extends Statement implements SwitchNode
switch(x) { case 5: case 6: a=100; break; case 9: a=33; break; default: throw new IllegalStateException(); };
switch(a) { ... }
the selector is "a",
and the contents of the { ... } are the entries.
SwitchExpr
)
SwitchExpr
)
switch(x) { case BANANA,PEAR: b=10; break; default: b=5; };
switch(x) { case 5,6 -> println("uhuh"); default -> println("nope"); };
SwitchEntry
,
SwitchExpr
,
SwitchNode
,
BreakStmt
,
YieldStmt
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration, SYMBOL_RESOLVER_KEY
Constructor and Description |
---|
SwitchStmt() |
SwitchStmt(Expression selector,
NodeList<SwitchEntry> entries) |
SwitchStmt(TokenRange tokenRange,
Expression selector,
NodeList<SwitchEntry> entries)
This constructor is used by the parser and is considered private.
|
Modifier and Type | Method and Description |
---|---|
<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.
|
SwitchStmt |
asSwitchStmt() |
SwitchStmt |
clone() |
NodeList<SwitchEntry> |
getEntries() |
SwitchEntry |
getEntry(int i) |
SwitchStmtMetaModel |
getMetaModel() |
Expression |
getSelector() |
void |
ifSwitchStmt(Consumer<SwitchStmt> action) |
boolean |
isSwitchStmt() |
boolean |
remove(Node node) |
boolean |
replace(Node node,
Node replacementNode) |
SwitchStmt |
setEntries(NodeList<SwitchEntry> entries) |
SwitchStmt |
setSelector(Expression selector) |
Optional<SwitchStmt> |
toSwitchStmt() |
asAssertStmt, asBlockStmt, asBreakStmt, asContinueStmt, asDoStmt, asEmptyStmt, asExplicitConstructorInvocationStmt, asExpressionStmt, asForEachStmt, asForStmt, asIfStmt, asLabeledStmt, asLocalClassDeclarationStmt, asReturnStmt, asSynchronizedStmt, asThrowStmt, asTryStmt, asUnparsableStmt, asWhileStmt, asYieldStmt, ifAssertStmt, ifBlockStmt, ifBreakStmt, ifContinueStmt, ifDoStmt, ifEmptyStmt, ifExplicitConstructorInvocationStmt, ifExpressionStmt, ifForEachStmt, ifForStmt, ifIfStmt, ifLabeledStmt, ifLocalClassDeclarationStmt, ifReturnStmt, ifSynchronizedStmt, ifThrowStmt, ifTryStmt, ifUnparsableStmt, ifWhileStmt, ifYieldStmt, isAssertStmt, isBlockStmt, isBreakStmt, isContinueStmt, isDoStmt, isEmptyStmt, isExplicitConstructorInvocationStmt, isExpressionStmt, isForEachStmt, isForStmt, isIfStmt, isLabeledStmt, isLocalClassDeclarationStmt, isReturnStmt, isSynchronizedStmt, isThrowStmt, isTryStmt, isUnparsableStmt, isWhileStmt, isYieldStmt, toAssertStmt, toBlockStmt, toBreakStmt, toContinueStmt, toDoStmt, toEmptyStmt, toExplicitConstructorInvocationStmt, toExpressionStmt, toForEachStmt, toForStmt, toIfStmt, toLabeledStmt, toLocalClassDeclarationStmt, toReturnStmt, toSynchronizedStmt, toThrowStmt, toTryStmt, toUnparsableStmt, toWhileStmt, toYieldStmt
addOrphanComment, containsData, customInitialization, equals, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getSymbolResolver, getTokenRange, getToStringPrettyPrinterConfiguration, hashCode, isAncestorOf, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, setToStringPrettyPrinterConfiguration, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
finalize, getClass, notify, notifyAll, wait, wait, wait
getComment, isEmpty
findAncestor, findAncestor, isDescendantOf
containsWithin, containsWithinRange, getBegin, getEnd
public SwitchStmt()
public SwitchStmt(Expression selector, NodeList<SwitchEntry> entries)
public SwitchStmt(TokenRange tokenRange, Expression selector, NodeList<SwitchEntry> entries)
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Visitable
accept
in interface Visitable
R
- the type of the return value of the visitorA
- the type the user argument passed to the visitorv
- the visitor implementationarg
- the argument passed to the visitor (of type A)public <A> void accept(VoidVisitor<A> v, A arg)
Visitable
public NodeList<SwitchEntry> getEntries()
getEntries
in interface SwitchNode
public SwitchEntry getEntry(int i)
getEntry
in interface SwitchNode
public Expression getSelector()
getSelector
in interface SwitchNode
public SwitchStmt setEntries(NodeList<SwitchEntry> entries)
setEntries
in interface SwitchNode
public SwitchStmt setSelector(Expression selector)
setSelector
in interface SwitchNode
public boolean remove(Node node)
remove
in interface SwitchNode
remove
in class Statement
public SwitchStmt clone()
clone
in interface SwitchNode
clone
in class Statement
public SwitchStmtMetaModel getMetaModel()
getMetaModel
in class Statement
public boolean replace(Node node, Node replacementNode)
replace
in interface SwitchNode
replace
in class Statement
public boolean isSwitchStmt()
isSwitchStmt
in class Statement
public SwitchStmt asSwitchStmt()
asSwitchStmt
in class Statement
public void ifSwitchStmt(Consumer<SwitchStmt> action)
ifSwitchStmt
in class Statement
public Optional<SwitchStmt> toSwitchStmt()
toSwitchStmt
in class Statement
Copyright © 2007–2019. All rights reserved.