Package: org.apache.groovy.contracts

## [Java] Class ThrowsIfViolation

- org.apache.groovy.contracts.ThrowsIfViolation

-     public class ThrowsIfViolation
      extends AssertionViolation

  Thrown whenever a `@ThrowsIf` exceptional-contract violation is detected by a `checked` arm-set: the method returned normally although a must-throw condition held, or threw a matching exception although no arm's condition held (the latter checked only for `exhaustive` arm-sets).

  Deliberately not the arm's declared exception: the declared exception is defined behaviour delivered at method entry, whereas this violation reports a broken implementation of the contract — late-throwing the declared exception would masquerade the bug as defined behaviour.

  See Also:
    AssertionViolation
  Since:
    6.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ThrowsIfViolation()` Creates a throws-if violation without an explicit detail message.
    `ThrowsIfViolation(Object o)` Creates a throws-if violation with an object-valued detail.
    `ThrowsIfViolation(boolean b)` Creates a throws-if violation with a boolean detail.
    `ThrowsIfViolation(char c)` Creates a throws-if violation with a char detail.
    `ThrowsIfViolation(int i)` Creates a throws-if violation with an int detail.
    `ThrowsIfViolation(long l)` Creates a throws-if violation with a long detail.
    `ThrowsIfViolation(float f)` Creates a throws-if violation with a float detail.
    `ThrowsIfViolation(double d)` Creates a throws-if violation with a double detail.

- - ### Constructor Detail

    - #### public ThrowsIfViolation()

      Creates a throws-if violation without an explicit detail message.

    - #### public ThrowsIfViolation(Object o)

      Creates a throws-if violation with an object-valued detail.

      Parameters:
        `o` - the detail object

    - #### public ThrowsIfViolation(boolean b)

      Creates a throws-if violation with a boolean detail.

      Parameters:
        `b` - the detail value

    - #### public ThrowsIfViolation(char c)

      Creates a throws-if violation with a char detail.

      Parameters:
        `c` - the detail value

    - #### public ThrowsIfViolation(int i)

      Creates a throws-if violation with an int detail.

      Parameters:
        `i` - the detail value

    - #### public ThrowsIfViolation(long l)

      Creates a throws-if violation with a long detail.

      Parameters:
        `l` - the detail value

    - #### public ThrowsIfViolation(float f)

      Creates a throws-if violation with a float detail.

      Parameters:
        `f` - the detail value

    - #### public ThrowsIfViolation(double d)

      Creates a throws-if violation with a double detail.

      Parameters:
        `d` - the detail value