Class LongRangeValidator

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, RangeValidator<Long>, Validator<Long>

public class LongRangeValidator extends AbstractComparableRangeValidator<Long>
A range validator for longs. The step value is considered relative either to the minimum value, if available, the maximum value, if available, or zero, in that order or priority.
Author:
Garret Wilson
  • Constructor Details

    • LongRangeValidator

      public LongRangeValidator()
      Default constructor with no value required and a step of one.
    • LongRangeValidator

      public LongRangeValidator(boolean valueRequired)
      Value required constructor with a step of one.
      Parameters:
      valueRequired - Whether the value must be non-null in order to be considered valid.
    • LongRangeValidator

      public LongRangeValidator(Long maximum)
      Maximum constructor with a minimum value of zero and a step of one.
      Parameters:
      maximum - The maximum value, inclusive, or null if the range has no upper bound.
    • LongRangeValidator

      public LongRangeValidator(Long minimum, Long maximum)
      Minimum and maximum constructor with a step of one.
      Parameters:
      minimum - The minimum value, inclusive, or null if the range has no lower bound.
      maximum - The maximum value, inclusive, or null if the range has no upper bound.
    • LongRangeValidator

      public LongRangeValidator(Long minimum, Long maximum, Long step)
      Minimum, maximum, and step constructor.
      Parameters:
      minimum - The minimum value, inclusive, or null if the range has no lower bound.
      maximum - The maximum value, inclusive, or null if the range has no upper bound.
      step - The step amount, or null if the range has no increment value specified.
    • LongRangeValidator

      public LongRangeValidator(Long maximum, boolean valueRequired)
      Minimum and value required constructor with a minimum value of zero and a step of one.
      Parameters:
      maximum - The maximum value, inclusive, or null if the range has no upper bound.
      valueRequired - Whether the value must be non-null in order to be considered valid.
    • LongRangeValidator

      public LongRangeValidator(Long minimum, Long maximum, boolean valueRequired)
      Minimum, maximum, and value required constructor with a step of one.
      Parameters:
      minimum - The minimum value, inclusive, or null if the range has no lower bound.
      maximum - The maximum value, inclusive, or null if the range has no upper bound.
      valueRequired - Whether the value must be non-null in order to be considered valid.
    • LongRangeValidator

      public LongRangeValidator(Long minimum, Long maximum, Long step, boolean valueRequired)
      Minimum, maximum, step, and value required constructor.
      Parameters:
      minimum - The minimum value, inclusive, or null if the range has no lower bound.
      maximum - The maximum value, inclusive, or null if the range has no upper bound.
      step - The step amount, or null if the range has no increment value specified.
      valueRequired - Whether the value must be non-null in order to be considered valid.
  • Method Details

    • isValidStep

      protected boolean isValidStep(Long value, Long step, Long base)
      Description copied from class: AbstractComparableRangeValidator
      Determines whether the given value falls on the correct step amount relative to the base value.
      Specified by:
      isValidStep in class AbstractComparableRangeValidator<Long>
      Parameters:
      value - The value to validate.
      step - The step value.
      base - The base (either the minimum or maximum value), or null if zero should be used as a base.
      Returns:
      true if the value is a valid step away from the given base.