Type Parameters:
S - the type of validator
All Known Subinterfaces:
PrimitiveIntegerValidator, PrimitiveUnsignedIntegerValidator

public interface PrimitiveIntegerComponent<S>
Validates the state of an int.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value that is being validated.
    int
    getValueOrDefault(int defaultValue)
    Returns the value that is being validated.
    isEqualTo(int expected)
    Ensures that the value is equal to expected.
    isEqualTo(int expected, String name)
    Ensures that the value is equal to expected.
    isNotEqualTo(int unwanted)
    Ensures that the value is not equal to unwanted.
    isNotEqualTo(int unwanted, String name)
    Ensures that the value is not equal to unwanted.
  • Method Details

    • getValue

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

      int getValueOrDefault(int 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
    • isEqualTo

      S isEqualTo(int 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

      S isEqualTo(int 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

      S isNotEqualTo(int 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

      S isNotEqualTo(int 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