Class Assertion<T extends Assertion>

java.lang.Object
org.apache.groovy.contracts.domain.Assertion<T>
Type Parameters:
T - the concrete assertion subtype used for logical composition
Direct Known Subclasses:
ClassInvariant, LoopInvariant, Postcondition, Precondition

public abstract class Assertion<T extends Assertion> extends Object

Base class for all assertion types.

  • Constructor Details

    • Assertion

      public Assertion()
      Creates an assertion that defaults to true.
    • Assertion

      public Assertion(BlockStatement blockStatement, BooleanExpression booleanExpression)
      Creates an assertion backed by the original block and normalized boolean expression.
      Parameters:
      blockStatement - the original contract block, or null if unavailable
      booleanExpression - the normalized expression to evaluate
  • Method Details

    • booleanExpression

      public BooleanExpression booleanExpression()
      Returns the boolean expression used when generating the runtime assertion.
      Returns:
      the current boolean expression
    • originalBlockStatement

      public BlockStatement originalBlockStatement()
      Returns the original block statement from which this assertion was derived.
      Returns:
      the original contract block, or null if it is unavailable
    • renew

      public void renew(BooleanExpression booleanExpression)
      Replaces the current boolean expression while preserving the existing source mapping strategy.
      Parameters:
      booleanExpression - the new boolean expression
    • and

      public void and(T other)
      Conjoins this assertion with another assertion of the same kind.
      Parameters:
      other - the assertion to combine with a logical AND
    • or

      public void or(T other)
      Disjoins this assertion with another assertion of the same kind.
      Parameters:
      other - the assertion to combine with a logical OR