Class CheckerDate

java.lang.Object
com.luchersol.core.util.AbstractChecker<Date,CheckerDate>
com.luchersol.core.specialized_checkers.time.temporal.CheckerDate
All Implemented Interfaces:
InterfaceCheckerDate<CheckerDate,Date>, InterfaceChecker<AbstractChecker<Date,CheckerDate>,Date>

public class CheckerDate extends AbstractChecker<Date,CheckerDate> implements InterfaceCheckerDate<CheckerDate,Date>
A specialized checker for Date instances, providing fluent API methods to assert temporal properties such as being before/after another date, inclusivity checks, range validations, and whether a date lies in the past or future.

Typical usage:


 Date deadline = ...;
 Date now = new Date();

 CheckerDate checker = CheckerDate.check(deadline)
     .isAfter(now)
     .inRange(now, new Date(now.getTime() + 86400000)) // within the next 24 hours
     .isFuture();
 

This class integrates with InterfaceCheckerDate for standardized temporal validations and supports chaining multiple assertions in a fluent, expressive style.

See Also:
  • Constructor Details

    • CheckerDate

      protected CheckerDate(Date date, String name)
      Constructs a new CheckerDate with the specified date and name.
      Parameters:
      date - the Date to be wrapped and checked
      name - the name identifying this checker function
  • Method Details

    • check

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

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

      protected CheckerDate self()
      Returns this instance (for fluent API usage).
      Specified by:
      self in class AbstractChecker<Date,CheckerDate>
      Returns:
      this CheckerDate instance
    • isBefore

      public CheckerDate isBefore(Date date)
      Checks if the date is before the specified date.
      Specified by:
      isBefore in interface InterfaceCheckerDate<CheckerDate,Date>
      Parameters:
      date - the date to compare with
      Returns:
      this CheckerDate instance for chaining
    • isBeforeOrEqual

      public CheckerDate isBeforeOrEqual(Date date)
      Checks if the date is before or equal to the specified date.
      Specified by:
      isBeforeOrEqual in interface InterfaceCheckerDate<CheckerDate,Date>
      Parameters:
      date - the date to compare with
      Returns:
      this CheckerDate instance for chaining
    • isAfter

      public CheckerDate isAfter(Date date)
      Checks if the date is after the specified date.
      Specified by:
      isAfter in interface InterfaceCheckerDate<CheckerDate,Date>
      Parameters:
      date - the date to compare with
      Returns:
      this CheckerDate instance for chaining
    • isAfterOrEqual

      public CheckerDate isAfterOrEqual(Date date)
      Checks if the date is after or equal to the specified date.
      Specified by:
      isAfterOrEqual in interface InterfaceCheckerDate<CheckerDate,Date>
      Parameters:
      date - the date to compare with
      Returns:
      this CheckerDate instance for chaining
    • inRange

      public CheckerDate inRange(Date date_1, Date date_2)
      Checks if the date is within the specified range (exclusive).
      Specified by:
      inRange in interface InterfaceCheckerDate<CheckerDate,Date>
      Parameters:
      date_1 - the start date (exclusive)
      date_2 - the end date (exclusive)
      Returns:
      this CheckerDate instance for chaining
    • isPast

      public CheckerDate isPast()
      Checks if the date is in the past (before the current date and time).
      Specified by:
      isPast in interface InterfaceCheckerDate<CheckerDate,Date>
      Returns:
      this CheckerDate instance for chaining
    • isFuture

      public CheckerDate isFuture()
      Checks if the date is in the future (after the current date and time).
      Specified by:
      isFuture in interface InterfaceCheckerDate<CheckerDate,Date>
      Returns:
      this CheckerDate instance for chaining