public class ElvisOperatorExpression extends TernaryExpression
def truePart = x def booleanPart = truePart as boolean booleanPart? truePart : yEven if x is no atomic expression, x will be evaluated only once. Example:
class Foo { def index=0 def getX(){ index++; return index } } def foo = new Foo() def result = foo.x ?: "false case" assert foo.index == 1 assert result == 1
Constructor and Description |
---|
ElvisOperatorExpression(Expression base,
Expression falseExpression) |
Modifier and Type | Method and Description |
---|---|
Expression |
transformExpression(ExpressionTransformer transformer)
Return a copy of the expression calling the transformer on any nested expressions
|
void |
visit(GroovyCodeVisitor visitor) |
getBooleanExpression, getFalseExpression, getText, getTrueExpression, getType, toString
setType, transformExpressions, transformExpressions
addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getNodeMetaData, getNodeMetaData, putNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, setSourcePosition
public ElvisOperatorExpression(Expression base, Expression falseExpression)
public void visit(GroovyCodeVisitor visitor)
visit
in class TernaryExpression
public Expression transformExpression(ExpressionTransformer transformer)
Expression
transformExpression
in class TernaryExpression