public class IfStmt extends Statement implements NodeWithCondition<IfStmt>
if(a==5) hurray() else boo();
the condition is a==5,
hurray() is the thenStmt, and boo() is the elseStmt.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 |
---|
IfStmt() |
IfStmt(Expression condition,
Statement thenStmt,
Statement elseStmt) |
IfStmt(TokenRange tokenRange,
Expression condition,
Statement thenStmt,
Statement elseStmt)
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.
|
IfStmt |
asIfStmt() |
IfStmt |
clone() |
Expression |
getCondition() |
Optional<Statement> |
getElseStmt() |
IfStmtMetaModel |
getMetaModel() |
Statement |
getThenStmt() |
boolean |
hasCascadingIfStmt()
This method returns true if the If Statement has an else branch and that branch is another If Statement.
|
boolean |
hasElseBlock()
This method returns true if the If Statement has an else branch and that branch is a block statement.
|
boolean |
hasElseBranch()
This method returns true if the If Statement has an else branch.
|
boolean |
hasThenBlock()
This method returns true if the then branch (which should be always present) is a block statement.
|
void |
ifIfStmt(Consumer<IfStmt> action) |
boolean |
isIfStmt() |
boolean |
remove(Node node) |
IfStmt |
removeElseStmt() |
boolean |
replace(Node node,
Node replacementNode) |
IfStmt |
setCondition(Expression condition) |
IfStmt |
setElseStmt(Statement elseStmt)
Sets the elseStmt
|
IfStmt |
setThenStmt(Statement thenStmt) |
Optional<IfStmt> |
toIfStmt() |
asAssertStmt, asBlockStmt, asBreakStmt, asContinueStmt, asDoStmt, asEmptyStmt, asExplicitConstructorInvocationStmt, asExpressionStmt, asForEachStmt, asForStmt, asLabeledStmt, asLocalClassDeclarationStmt, asReturnStmt, asSwitchStmt, asSynchronizedStmt, asThrowStmt, asTryStmt, asUnparsableStmt, asWhileStmt, ifAssertStmt, ifBlockStmt, ifBreakStmt, ifContinueStmt, ifDoStmt, ifEmptyStmt, ifExplicitConstructorInvocationStmt, ifExpressionStmt, ifForEachStmt, ifForStmt, ifLabeledStmt, ifLocalClassDeclarationStmt, ifReturnStmt, ifSwitchStmt, ifSynchronizedStmt, ifThrowStmt, ifTryStmt, ifUnparsableStmt, ifWhileStmt, isAssertStmt, isBlockStmt, isBreakStmt, isContinueStmt, isDoStmt, isEmptyStmt, isExplicitConstructorInvocationStmt, isExpressionStmt, isForEachStmt, isForStmt, isLabeledStmt, isLocalClassDeclarationStmt, isReturnStmt, isSwitchStmt, isSynchronizedStmt, isThrowStmt, isTryStmt, isUnparsableStmt, isWhileStmt, toAssertStmt, toBlockStmt, toBreakStmt, toContinueStmt, toDoStmt, toEmptyStmt, toExplicitConstructorInvocationStmt, toExpressionStmt, toForEachStmt, toForStmt, toLabeledStmt, toLocalClassDeclarationStmt, toReturnStmt, toSwitchStmt, toSynchronizedStmt, toThrowStmt, toTryStmt, toUnparsableStmt, toWhileStmt
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
findAncestor, findAncestor, isDescendantOf
containsWithin, containsWithinRange, getBegin, getEnd
public IfStmt()
public IfStmt(Expression condition, Statement thenStmt, Statement elseStmt)
public IfStmt(TokenRange tokenRange, Expression condition, Statement thenStmt, Statement elseStmt)
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 Expression getCondition()
getCondition
in interface NodeWithCondition<IfStmt>
public Statement getThenStmt()
public IfStmt setCondition(Expression condition)
setCondition
in interface NodeWithCondition<IfStmt>
public IfStmt setElseStmt(Statement elseStmt)
elseStmt
- the elseStmt, can be nullpublic IfStmt removeElseStmt()
public boolean hasThenBlock()
public boolean hasElseBlock()
public boolean hasCascadingIfStmt()
public boolean hasElseBranch()
public IfStmtMetaModel getMetaModel()
getMetaModel
in class Statement
Copyright © 2007–2019. All rights reserved.