Class DoubleRangeValidator

java.lang.Object
com.dlsc.formsfx.model.validators.CustomValidator<Double>
com.dlsc.formsfx.model.validators.DoubleRangeValidator
All Implemented Interfaces:
Validator<Double>

public class DoubleRangeValidator
extends CustomValidator<Double>
A DoubleRangeValidator checks if a double value is between a minimum and a maximum value.
Author:
Sacha Schmid, Rinesch Murugathas
  • Method Details

    • between

      public static DoubleRangeValidator between​(double min, double max, String errorMessage)
      Creates a DoubleRangeValidator with given lower and upper bounds.
      Parameters:
      min - The lower bound for the validation.
      max - The upper bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new DoubleRangeValidator.
      Throws:
      IllegalArgumentException - Thrown if the maximum is not larger than or equal to the minimum.
    • atLeast

      public static DoubleRangeValidator atLeast​(double min, String errorMessage)
      Creates a DoubleRangeValidator with a given lower bound.
      Parameters:
      min - The lower bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new DoubleRangeValidator.
    • upTo

      public static DoubleRangeValidator upTo​(double max, String errorMessage)
      Creates a DoubleRangeValidator with a given upper bound.
      Parameters:
      max - The upper bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new DoubleRangeValidator.
    • exactly

      public static DoubleRangeValidator exactly​(double value, String errorMessage)
      Creates a DoubleRangeValidator with a given lower and upper bound, which are equal.
      Parameters:
      value - The lower and upper bound for the validation.
      errorMessage - The error message that is returned if the validation fails.
      Returns:
      Returns a new DoubleRangeValidator.
    • createResult

      protected ValidationResult createResult​(boolean result)
      Creates a ValidationResult based on the validation result.
      Parameters:
      result - The result of the validation.
      Returns:
      Returns a new ValidationResult containing result and message.