public final class CaseStatement extends GoloStatement<CaseStatement> implements Alternatives<Block>
case
node.
This node describe tree such as:
case {
when condition_1 {
action_1
}
when condition_2 {
action_2
}
otherwise {
default_action
}
}
Modifier and Type | Method and Description |
---|---|
void |
accept(GoloIrVisitor visitor)
Accept the visitor.
|
static CaseStatement |
cases()
Creates an empty case switch.
|
java.util.List<GoloElement<?>> |
children()
Returns a list of all the direct children of this node.
|
java.util.List<WhenClause<Block>> |
getClauses() |
Block |
getOtherwise() |
CaseStatement |
otherwise(java.lang.Object action)
Defines the default alternative clause.
|
void |
replaceElement(GoloElement<?> original,
GoloElement<?> newElement)
Replace a child.
|
protected CaseStatement |
self() |
CaseStatement |
then(java.lang.Object action)
Defines the action of the previous clause.
|
CaseStatement |
when(java.lang.Object cond)
Defines a new alternative clause.
|
of
ancestor, ancestor, ancestorOfType, cantConvert, cantReplace, cantReplace, children, children, descendants, descendants, descendants, documentation, documentation, doesNotContain, enclosingModule, getLocalReferenceTable, hasParent, hasPosition, inheritedMetadata, makeParentOf, metadata, metadata, next, next, next, ofAST, parent, positionInSourceCode, positionInSourceCode, previous, previous, previous, replaceInParentBy, walk
public static CaseStatement cases()
protected CaseStatement self()
self
in class GoloElement<CaseStatement>
public CaseStatement when(java.lang.Object cond)
This is a builder method.
when
in interface Alternatives<Block>
cond
- an expression node defining the clause.public CaseStatement then(java.lang.Object action)
This is a builder method.
It must be called after a call to when
. For instance
alternative.when(condition).then(action);
then
in interface Alternatives<Block>
action
- a Block
containing the statements to execute.public CaseStatement otherwise(java.lang.Object action)
This is a builder method.
otherwise
in interface Alternatives<Block>
action
- a Block
containing the statements to execute.public java.util.List<WhenClause<Block>> getClauses()
getClauses
in interface Alternatives<Block>
public Block getOtherwise()
getOtherwise
in interface Alternatives<Block>
public void accept(GoloIrVisitor visitor)
This method should only call the visitor visitXXXX
method.
The children of this node will be visited by the
GoloElement.walk(GoloIrVisitor)
method.
accept
in class GoloElement<CaseStatement>
public java.util.List<GoloElement<?>> children()
children
in class GoloElement<CaseStatement>
public void replaceElement(GoloElement<?> original, GoloElement<?> newElement)
Replace original
with newElement
if original
is a child of this node
and type matches.
replaceElement
in class GoloElement<CaseStatement>
original
- the original value to replace. Must be a child of this nodenewElement
- the element to replace with. Type must match.GoloElement.cantReplace()
,
GoloElement.cantReplace(GoloElement, GoloElement)
,
GoloElement.doesNotContain(GoloElement)
,
GoloElement.cantConvert(String, Object)