Class IntervalSchedule

java.lang.Object
org.sterl.spring.persistent_tasks.api.IntervalSchedule
All Implemented Interfaces:
Serializable, Schedule

public final class IntervalSchedule extends Object implements Schedule
A schedule based on a fixed time interval.

Examples:

  • Duration.ofHours(1) - Every hour
  • Duration.ofMinutes(30) - Every 30 minutes
  • Duration.ofDays(1) - Every day
See Also:
  • Constructor Details

    • IntervalSchedule

      public IntervalSchedule(Duration interval)
      Creates a new interval schedule.
      Parameters:
      interval - the time interval between executions
      Throws:
      IllegalArgumentException - if interval is null, zero, or negative
  • Method Details

    • next

      public OffsetDateTime next(OffsetDateTime from)
      Description copied from interface: Schedule
      Calculates the next execution time from the given time.
      Specified by:
      next in interface Schedule
      Parameters:
      from - the reference time to calculate from
      Returns:
      the next execution time after the given time
    • description

      public String description()
      Description copied from interface: Schedule
      Returns a human-readable description of this schedule.
      Specified by:
      description in interface Schedule
      Returns:
      description of the schedule
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getInterval

      public Duration getInterval()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object