Class CheckerDuration

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

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

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

  • Constructor Details

    • CheckerDuration

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

    • check

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public CheckerDuration isEqual(Duration other)
      Checks if the duration is equal to another duration.
      Parameters:
      other - the other duration to compare with
      Returns:
      this CheckerDuration instance for chaining