All Superinterfaces:
ComparableComponent<PrimitiveDoubleValidator,Double>, DecimalNumberComponent<PrimitiveDoubleValidator>, FixedPrecisionDecimalNumberComponent<PrimitiveDoubleValidator>, NegativeNumberComponent<PrimitiveDoubleValidator>, PositiveNumberComponent<PrimitiveDoubleValidator>, ValidatorComponent<PrimitiveDoubleValidator,Double>, ZeroNumberComponent<PrimitiveDoubleValidator>

Validates the state of a double.
  • Method Details

    • getValue

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

      double getValueOrDefault(double 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

      PrimitiveDoubleValidator isEqualTo(double 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 per Double.equals(Object)
    • isEqualTo

      PrimitiveDoubleValidator isEqualTo(double 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 per {@link Double#equals(Object)}
    • isNotEqualTo

      PrimitiveDoubleValidator isNotEqualTo(double 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 per Double.equals(Object)
    • isNotEqualTo

      PrimitiveDoubleValidator isNotEqualTo(double 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 per Double.equals(Object)
    • isMultipleOf

      PrimitiveDoubleValidator isMultipleOf(double factor)
      Ensures that the value is a multiple of factor.
      Parameters:
      factor - the number being multiplied
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is:
      • not a multiple of factor
      • not a number
    • isMultipleOf

      PrimitiveDoubleValidator isMultipleOf(double factor, String name)
      Ensures that the value is a multiple of factor.
      Parameters:
      factor - the number being multiplied
      name - the name of the factor
      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 a multiple of factor
      • the value is not a number
    • isNotMultipleOf

      PrimitiveDoubleValidator isNotMultipleOf(double factor)
      Ensures that the value is not a multiple of factor.
      Parameters:
      factor - the number being multiplied
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is a multiple of factor
    • isNotMultipleOf

      PrimitiveDoubleValidator isNotMultipleOf(double factor, String name)
      Ensures that the value is not a multiple of factor.
      Parameters:
      factor - the number being multiplied
      name - the name of the factor
      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 a multiple of factor
    • isLessThan

      PrimitiveDoubleValidator isLessThan(double maximumExclusive)
      Ensures that the value is less than an upper bound.
      Parameters:
      maximumExclusive - the exclusive upper bound
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is:
      • greater than or equal to maximumExclusive
      • not a number
    • isLessThan

      PrimitiveDoubleValidator isLessThan(double maximumExclusive, String name)
      Ensures that the value is less than an upper bound.
      Parameters:
      maximumExclusive - the exclusive upper bound
      name - the name of the upper bound
      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 greater than or equal to maximumExclusive
      • the value is not a number
    • isLessThanOrEqualTo

      PrimitiveDoubleValidator isLessThanOrEqualTo(double maximumInclusive)
      Ensures that the value is less than or equal to a maximum value.
      Parameters:
      maximumInclusive - the inclusive upper value
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is:
      • greater than maximumInclusive
      • not a number
    • isLessThanOrEqualTo

      PrimitiveDoubleValidator isLessThanOrEqualTo(double maximumInclusive, String name)
      Ensures that the value is less than or equal to a maximum value.
      Parameters:
      maximumInclusive - the maximum value
      name - the name of the maximum 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 greater than maximumInclusive
      • the value is not a number
    • isGreaterThanOrEqualTo

      PrimitiveDoubleValidator isGreaterThanOrEqualTo(double minimumInclusive)
      Ensures that the value is greater than or equal to a minimum value.
      Parameters:
      minimumInclusive - the minimum value
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is:
      • less than minimumInclusive
      • not a number
    • isGreaterThanOrEqualTo

      PrimitiveDoubleValidator isGreaterThanOrEqualTo(double minimumInclusive, String name)
      Ensures that the value is greater than or equal a minimum value.
      Parameters:
      minimumInclusive - the minimum value
      name - the name of the minimum 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 less than minimumInclusive
      • the value is not a number
    • isGreaterThan

      PrimitiveDoubleValidator isGreaterThan(double minimumExclusive)
      Ensures that the value is greater than a lower bound.
      Parameters:
      minimumExclusive - the exclusive lower bound
      Returns:
      this
      Throws:
      IllegalArgumentException - if the value is:
      • less than or equal to minimumExclusive
      • not a number
    • isGreaterThan

      PrimitiveDoubleValidator isGreaterThan(double minimumExclusive, String name)
      Ensures that the value is greater than a lower bound.
      Parameters:
      minimumExclusive - the exclusive lower bound
      name - the name of the lower bound
      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 less or equal to minimumExclusive
      • the value is not a number
    • isBetween

      PrimitiveDoubleValidator isBetween(double minimumInclusive, double maximumExclusive)
      Ensures that the value is within a range.
      Parameters:
      minimumInclusive - the lower bound of the range (inclusive)
      maximumExclusive - the upper bound of the range (exclusive)
      Returns:
      this
      Throws:
      IllegalArgumentException - if:
      • minimumInclusive is greater than maximumExclusive
      • the value is greater than or equal to maximumExclusive
      • the value is not a number
    • isBetween

      PrimitiveDoubleValidator isBetween(double minimum, boolean minimumIsInclusive, double maximum, boolean maximumIsInclusive)
      Ensures that the value is within a range.
      Parameters:
      minimum - the lower bound of the range
      minimumIsInclusive - true if the lower bound of the range is inclusive
      maximum - the upper bound of the range
      maximumIsInclusive - true if the upper bound of the range is inclusive
      Returns:
      this
      Throws:
      IllegalArgumentException - if:
      • minimum is greater than maximum
      • minimumIsInclusive is true and the value is less than minimum
      • minimumIsInclusive is false and the value is less than or equal to minimum
      • maximumIsInclusive is true and the value is greater than maximum
      • maximumInclusive is false and the value is greater than or equal to maximum
      • the value is not a number