public class TenaryOperation extends Object implements Expression
condition ? expr : expr
.
If the condition evaluates to true the first expression is evaluated and its result returned. Otherwise the second expression is evaluated and its result is returned.
Modifier and Type | Field and Description |
---|---|
protected Expression |
conditionExpression |
protected Expression |
leftExpression |
protected Expression |
rightExpression |
Constructor and Description |
---|
TenaryOperation(Expression conditionExpression,
Expression leftExpression,
Expression rightExpression)
Creates a new instance for the given condition and expressions.
|
Modifier and Type | Method and Description |
---|---|
Expression |
copy()
Creates a deep copy of the expression which can be modified without affecting the original expression.
|
Object |
eval(LocalRenderContext ctx)
Evaluates the expression into an object using the given context.
|
Class<?> |
getType()
Returns the Java class of the objects yielded by this expression.
|
boolean |
isConstant()
Determines if the expression is constant.
|
Expression |
propagateVisitor(ExpressionVisitor visitor)
Visits all child nodes and then the node itself.
|
Expression |
reduce()
Reduces and optimizes the expression if possible.
|
protected Expression conditionExpression
protected Expression leftExpression
protected Expression rightExpression
public TenaryOperation(Expression conditionExpression, Expression leftExpression, Expression rightExpression)
conditionExpression
- the expression to evaluate to determine which expression to evalaute and returnleftExpression
- the expression to evaluate and return if the condition is truerightExpression
- the expression to evaluate and return if the condition is falsepublic Object eval(LocalRenderContext ctx)
Expression
eval
in interface Expression
ctx
- the current rendering contextpublic Expression propagateVisitor(ExpressionVisitor visitor)
Expression
propagateVisitor
in interface Expression
visitor
- the visitor to invoke for all child nodes and on the node itselfpublic Expression reduce()
Expression
reduce
in interface Expression
public boolean isConstant()
Expression
isConstant
in interface Expression
public Expression copy()
Expression
copy
in interface Expression
public Class<?> getType()
Expression
getType
in interface Expression
Copyright © 2018. All rights reserved.