Class ExpressionUtils

java.lang.Object
org.apache.groovy.contracts.util.ExpressionUtils

public final class ExpressionUtils extends Object

Internal utility class for extracting a boolean expression from the given expression or statement.

See Also:
  • Method Details

    • getBooleanExpression

      public static List<BooleanExpression> getBooleanExpression(ClosureExpression closureExpression)
      Returns all BooleanExpression instances found in the given ClosureExpression. 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

      public static String describeStatementKind(Statement statement)
      Names the kind of the given statement for an error message, in the plural: "return statements" for a return statement, "try-catch statements" for a try statement.
      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 all BooleanExpression instances found in the given BlockStatement.
    • getBooleanExpression

      public static BooleanExpression getBooleanExpression(List<BooleanExpression> booleanExpressions)
      Collapses the supplied boolean expressions into a single expression combined with logical AND.
      Parameters:
      booleanExpressions - the expressions to combine
      Returns:
      the combined expression, or true if the input is empty