Class CheckerPeriod

java.lang.Object
util.AbstractChecker<Period,CheckerPeriod>
specialized_checkers.time.CheckerPeriod
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Period,CheckerPeriod>,Period>

public class CheckerPeriod extends AbstractChecker<Period,CheckerPeriod>
CheckerPeriod is a specialized checker for validating and performing assertions on Period values.

It provides a fluent API for common period validations such as checking positivity, negativity, zero, and comparisons with other periods or temporal units.

  • Constructor Details

    • CheckerPeriod

      protected CheckerPeriod(Period period, String name)
      Constructs a new CheckerPeriod with the specified period and name.
      Parameters:
      period - the Period to be associated with this checker
      name - the name of the checker
  • Method Details

    • check

      public static CheckerPeriod check(Period period, String name)
      Creates a new CheckerPeriod instance for the given period and name.
      Parameters:
      period - the period value to be checked
      name - the name to identify the period in error messages
      Returns:
      a CheckerPeriod instance for further validations
    • check

      public static CheckerPeriod check(Period period)
      Creates a new CheckerPeriod instance for the given period with a default name.
      Parameters:
      period - the period value to be checked
      Returns:
      a CheckerPeriod instance for further validations
    • self

      protected CheckerPeriod self()
      Returns this instance (for fluent API usage).
      Specified by:
      self in class AbstractChecker<Period,CheckerPeriod>
      Returns:
      this CheckerPeriod instance
    • isPositive

      public CheckerPeriod isPositive()
      Checks if the period is positive (greater than zero).
      Returns:
      this CheckerPeriod instance for chaining
    • isNegative

      public CheckerPeriod isNegative()
      Checks if the period is negative (less than zero).
      Returns:
      this CheckerPeriod instance for chaining
    • isZero

      public CheckerPeriod isZero()
      Checks if the period is zero.
      Returns:
      this CheckerPeriod instance for chaining
    • isGreaterThan

      public CheckerPeriod isGreaterThan(TemporalUnit temporalUnit, double time)
      Checks if the period is greater than the specified time in the given temporal unit.
      Parameters:
      temporalUnit - the unit of time to compare (e.g., YEARS, MONTHS, DAYS)
      time - the value to compare against
      Returns:
      this CheckerPeriod instance for chaining
    • isGreaterOrEqualThan

      public CheckerPeriod isGreaterOrEqualThan(TemporalUnit temporalUnit, double time)
      Checks if the period is greater than or equal to the specified time in the given temporal unit.
      Parameters:
      temporalUnit - the unit of time to compare (e.g., YEARS, MONTHS, DAYS)
      time - the value to compare against
      Returns:
      this CheckerPeriod instance for chaining
    • isLessThan

      public CheckerPeriod isLessThan(TemporalUnit temporalUnit, double time)
      Checks if the period is less than the specified time in the given temporal unit.
      Parameters:
      temporalUnit - the unit of time to compare (e.g., YEARS, MONTHS, DAYS)
      time - the value to compare against
      Returns:
      this CheckerPeriod instance for chaining
    • isLessOrEqualThan

      public CheckerPeriod isLessOrEqualThan(TemporalUnit temporalUnit, double time)
      Checks if the period is less than or equal to the specified time in the given temporal unit.
      Parameters:
      temporalUnit - the unit of time to compare (e.g., YEARS, MONTHS, DAYS)
      time - the value to compare against
      Returns:
      this CheckerPeriod instance for chaining
    • isEqual

      public CheckerPeriod isEqual(TemporalUnit temporalUnit, double time)
      Checks if the period is equal to the specified time in the given temporal unit.
      Parameters:
      temporalUnit - the unit of time to compare (e.g., YEARS, MONTHS, DAYS)
      time - the value to compare against
      Returns:
      this CheckerPeriod instance for chaining
    • isGreaterThan

      public CheckerPeriod isGreaterThan(Period other)
      Checks if the period is greater than another period.
      Parameters:
      other - the other period to compare with
      Returns:
      this CheckerPeriod instance for chaining
    • isGreaterOrEqualThan

      public CheckerPeriod isGreaterOrEqualThan(Period other)
      Checks if the period is greater than or equal to another period.
      Parameters:
      other - the other period to compare with
      Returns:
      this CheckerPeriod instance for chaining
    • isLessThan

      public CheckerPeriod isLessThan(Period other)
      Checks if the period is less than another period.
      Parameters:
      other - the other period to compare with
      Returns:
      this CheckerPeriod instance for chaining
    • isLessOrEqualThan

      public CheckerPeriod isLessOrEqualThan(Period other)
      Checks if the period is less than or equal to another period.
      Parameters:
      other - the other period to compare with
      Returns:
      this CheckerPeriod instance for chaining
    • isEqual

      public CheckerPeriod isEqual(Period other)
      Checks if the period is equal to another period.
      Parameters:
      other - the other period to compare with
      Returns:
      this CheckerPeriod instance for chaining