Package team.unnamed.mocha.parser.ast
Class TernaryConditionalExpression
java.lang.Object
team.unnamed.mocha.parser.ast.TernaryConditionalExpression
- All Implemented Interfaces:
Expression
Ternary conditional expression implementation, similar to
"if {...} else {...}" expressions in other languages.
If the conditional expression evaluates to a
truthy value, then trueExpression is evaluated
as the result, otherwise, falseExpression is.
Example ternary conditional expressions: true ? 1 : 0,
(age > 18) ? 'adult' : 'minor', open ? 'open' : 'closed'
- Since:
- 3.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionTernaryConditionalExpression(@NotNull Expression conditional, @NotNull Expression trueExpression, @NotNull Expression falseExpression) -
Method Summary
Modifier and TypeMethodDescription@NotNull ExpressionGets the expression condition.voidcondition(@NotNull Expression condition) Sets the expression condition.boolean@NotNull ExpressionGets the expression that should be used when condition is evaluated as a falsy value.voidfalseExpression(@NotNull Expression falseExpression) Sets the expression that should be used when condition is evaluated as a falsy value.inthashCode()toString()@NotNull ExpressionGets the expression that should be used when condition is evaluated as a truthy value.voidtrueExpression(@NotNull Expression trueExpression) Sets the expression that should be used when condition is evaluated as a truthy value.<R> Rvisit(@NotNull ExpressionVisitor<R> visitor) Visits this expression with the given visitor.
-
Constructor Details
-
TernaryConditionalExpression
public TernaryConditionalExpression(@NotNull @NotNull Expression conditional, @NotNull @NotNull Expression trueExpression, @NotNull @NotNull Expression falseExpression)
-
-
Method Details
-
condition
Gets the expression condition.- Since:
- 3.0.0
-
condition
Sets the expression condition.- Parameters:
condition- The condition- Since:
- 3.0.0
-
trueExpression
Gets the expression that should be used when condition is evaluated as a truthy value.- Since:
- 3.0.0
-
trueExpression
Sets the expression that should be used when condition is evaluated as a truthy value.- Parameters:
trueExpression- The true expression- Since:
- 3.0.0
-
falseExpression
Gets the expression that should be used when condition is evaluated as a falsy value.- Since:
- 3.0.0
-
falseExpression
Sets the expression that should be used when condition is evaluated as a falsy value.- Parameters:
falseExpression- The false expression- Since:
- 3.0.0
-
visit
Description copied from interface:ExpressionVisits this expression with the given visitor.- Specified by:
visitin interfaceExpression- Type Parameters:
R- The visit result return type- Parameters:
visitor- The expression visitor- Returns:
- The visit result
-
toString
-
equals
-
hashCode
public int hashCode()
-