public final 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, asSwitchEntryStmt, asSwitchStmt, asSynchronizedStmt, asThrowStmt, asTryStmt, asUnparsableStmt, asWhileStmt, ifAssertStmt, ifBlockStmt, ifBreakStmt, ifContinueStmt, ifDoStmt, ifEmptyStmt, ifExplicitConstructorInvocationStmt, ifExpressionStmt, ifForeachStmt, ifForStmt, ifLabeledStmt, ifLocalClassDeclarationStmt, ifReturnStmt, ifSwitchEntryStmt, ifSwitchStmt, ifSynchronizedStmt, ifThrowStmt, ifTryStmt, ifUnparsableStmt, ifWhileStmt, isAssertStmt, isBlockStmt, isBreakStmt, isContinueStmt, isDoStmt, isEmptyStmt, isExplicitConstructorInvocationStmt, isExpressionStmt, isForeachStmt, isForStmt, isLabeledStmt, isLocalClassDeclarationStmt, isReturnStmt, isSwitchEntryStmt, isSwitchStmt, isSynchronizedStmt, isThrowStmt, isTryStmt, isUnparsableStmt, isWhileStmt, toAssertStmt, toBlockStmt, toBreakStmt, toContinueStmt, toDoStmt, toEmptyStmt, toExplicitConstructorInvocationStmt, toExpressionStmt, toForeachStmt, toForStmt, toLabeledStmt, toLocalClassDeclarationStmt, toReturnStmt, toSwitchEntryStmt, toSwitchStmt, toSynchronizedStmt, toThrowStmt, toTryStmt, toUnparsableStmt, toWhileStmt
addOrphanComment, containsData, customInitialization, equals, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findParent, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getSymbolResolver, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
finalize, getClass, notify, notifyAll, wait, wait, wait
getAncestorOfType
containsWithin, getBegin, getEnd, isPositionedAfter, isPositionedBefore
public IfStmt()
public IfStmt(Expression condition, Statement thenStmt, Statement elseStmt)
@Generated(value="com.github.javaparser.generator.core.node.MainConstructorGenerator") public IfStmt(TokenRange tokenRange, Expression condition, Statement thenStmt, Statement elseStmt)
@Generated(value="com.github.javaparser.generator.core.node.AcceptGenerator") 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)@Generated(value="com.github.javaparser.generator.core.node.AcceptGenerator") public <A> void accept(VoidVisitor<A> v, A arg)
Visitable
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public Expression getCondition()
getCondition
in interface NodeWithCondition<IfStmt>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public Optional<Statement> getElseStmt()
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public Statement getThenStmt()
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public IfStmt setCondition(Expression condition)
setCondition
in interface NodeWithCondition<IfStmt>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public IfStmt setElseStmt(Statement elseStmt)
elseStmt
- the elseStmt, can be null@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public IfStmt setThenStmt(Statement thenStmt)
@Generated(value="com.github.javaparser.generator.core.node.RemoveMethodGenerator") public boolean remove(Node node)
@Generated(value="com.github.javaparser.generator.core.node.RemoveMethodGenerator") public IfStmt removeElseStmt()
public boolean hasThenBlock()
public boolean hasElseBlock()
public boolean hasCascadingIfStmt()
public boolean hasElseBranch()
@Generated(value="com.github.javaparser.generator.core.node.CloneGenerator") public IfStmt clone()
@Generated(value="com.github.javaparser.generator.core.node.GetMetaModelGenerator") public IfStmtMetaModel getMetaModel()
getMetaModel
in class Statement
@Generated(value="com.github.javaparser.generator.core.node.ReplaceMethodGenerator") public boolean replace(Node node, Node replacementNode)
@Generated(value="com.github.javaparser.generator.core.node.TypeCastingGenerator") public boolean isIfStmt()
@Generated(value="com.github.javaparser.generator.core.node.TypeCastingGenerator") public IfStmt asIfStmt()
@Generated(value="com.github.javaparser.generator.core.node.TypeCastingGenerator") public void ifIfStmt(Consumer<IfStmt> action)
Copyright © 2007–2018. All rights reserved.