Class TernaryToIfStatementConverter
java.lang.Object
org.codehaus.groovy.transform.tailrec.TernaryToIfStatementConverter
Since a ternary statement has more than one exit point tail-recursiveness testing cannot be easily done.
Therefore this class translates a ternary statement (or Elvis operator) into the equivalent if-else statement.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvert(ReturnStatement statementWithInnerTernaryExpression) Rewrites a return statement containing a ternary or Elvis expression into an equivalent if/else statement.
-
Constructor Details
-
TernaryToIfStatementConverter
public TernaryToIfStatementConverter()
-
-
Method Details
-
convert
Rewrites a return statement containing a ternary or Elvis expression into an equivalent if/else statement.- Parameters:
statementWithInnerTernaryExpression- the return statement to convert- Returns:
- the converted statement, or the original statement if no ternary expression is present
-