Package org.apache.groovy.contracts.util
Class ExpressionUtils
java.lang.Object
org.apache.groovy.contracts.util.ExpressionUtils
Internal utility class for extracting a boolean expression from the given expression or statement.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdescribeStatementKind(Statement statement) Names the kind of the given statement for an error message, in the plural:"return statements"for areturnstatement,"try-catch statements"for atrystatement.static BooleanExpressiongetBooleanExpression(List<BooleanExpression> booleanExpressions) Collapses the supplied boolean expressions into a single expression combined with logical AND.static List<BooleanExpression>getBooleanExpression(ClosureExpression closureExpression) Returns allBooleanExpressioninstances found in the givenClosureExpression.static List<BooleanExpression>getBooleanExpressionsFromAssertionStatements(BlockStatement blockStatement) Returns allBooleanExpressioninstances found in the givenBlockStatement.
-
Method Details
-
getBooleanExpression
Returns allBooleanExpressioninstances found in the givenClosureExpression. A statement that is not an expression statement holds no condition and is left out; callers report such a statement before asking for the conditions. -
describeStatementKind
Names the kind of the given statement for an error message, in the plural:"return statements"for areturnstatement,"try-catch statements"for atrystatement.- Parameters:
statement- the statement to describe- Returns:
- the kind of statement, derived from the statement's class name
-
getBooleanExpressionsFromAssertionStatements
public static List<BooleanExpression> getBooleanExpressionsFromAssertionStatements(BlockStatement blockStatement) Returns allBooleanExpressioninstances found in the givenBlockStatement. -
getBooleanExpression
Collapses the supplied boolean expressions into a single expression combined with logical AND.- Parameters:
booleanExpressions- the expressions to combine- Returns:
- the combined expression, or
trueif the input is empty
-