Interface PrimitiveBooleanValidator

All Superinterfaces:
ValidatorComponent<PrimitiveBooleanValidator,Boolean>

public interface PrimitiveBooleanValidator extends ValidatorComponent<PrimitiveBooleanValidator,Boolean>
Validates the state of a boolean.
  • Method Details

    • getValue

      boolean getValue()
      Returns the value that is being validated.
      Returns:
      the value
      Throws:
      IllegalStateException - if a previous validation failed
    • getValueOrDefault

      boolean getValueOrDefault(boolean defaultValue)
      Returns the value that is being validated.
      Parameters:
      defaultValue - the fallback value in case of a validation failure
      Returns:
      the value, or defaultValue if a previous validation failed
    • isTrue

      Ensures that the value is true.
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is false
    • isFalse

      Ensures that the value is false.
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is true
    • isEqualTo

      PrimitiveBooleanValidator isEqualTo(boolean expected)
      Ensures that the value is equal to expected.
      Parameters:
      expected - the expected value
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is not equal to expected
    • isEqualTo

      PrimitiveBooleanValidator isEqualTo(boolean expected, String name)
      Ensures that the value is equal to expected.
      Parameters:
      expected - the expected value
      name - the name of the expected value
      Returns:
      this
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the value is not equal to expected
    • isNotEqualTo

      PrimitiveBooleanValidator isNotEqualTo(boolean unwanted)
      Ensures that the value is not equal to unwanted.
      Parameters:
      unwanted - the value to compare to
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is equal to unwanted
    • isNotEqualTo

      PrimitiveBooleanValidator isNotEqualTo(boolean unwanted, String name)
      Ensures that the value is not equal to unwanted.
      Parameters:
      unwanted - the value to compare to
      name - the name of the other value
      Returns:
      this
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the value is equal to unwanted