Package org.jobrunr.scheduling
Class Schedule
- java.lang.Object
-
- org.jobrunr.scheduling.Schedule
-
- All Implemented Interfaces:
java.lang.Comparable<Schedule>
- Direct Known Subclasses:
CronExpression
,Interval
public abstract class Schedule extends java.lang.Object implements java.lang.Comparable<Schedule>
-
-
Field Summary
Fields Modifier and Type Field Description static int
SMALLEST_SCHEDULE_IN_SECONDS
-
Constructor Summary
Constructors Constructor Description Schedule()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Schedule schedule)
Compare twoSchedule
objects based on next occurrence.boolean
equals(java.lang.Object obj)
int
hashCode()
abstract java.time.Instant
next(java.time.Instant createdAtInstant, java.time.Instant currentInstant, java.time.ZoneId zoneId)
Calculates the next occurrence based on the creation time and the provided base time.java.time.Instant
next(java.time.Instant createdAt, java.time.ZoneId zoneId)
Calculates the next occurrence based on the creation time and the current time.abstract void
validateSchedule()
-
-
-
Field Detail
-
SMALLEST_SCHEDULE_IN_SECONDS
public static final int SMALLEST_SCHEDULE_IN_SECONDS
- See Also:
- Constant Field Values
-
-
Method Detail
-
next
public java.time.Instant next(java.time.Instant createdAt, java.time.ZoneId zoneId)
Calculates the next occurrence based on the creation time and the current time.- Parameters:
createdAt
- Instant object when the schedule was first createdzoneId
- the zone for which to calculate the schedule- Returns:
- Instant of the next occurrence.
-
next
@VisibleFor("testing") public abstract java.time.Instant next(java.time.Instant createdAtInstant, java.time.Instant currentInstant, java.time.ZoneId zoneId)
Calculates the next occurrence based on the creation time and the provided base time.- Parameters:
createdAtInstant
- Instant object when the schedule was first createdcurrentInstant
- Instant object used to calculate next occurrence (normally Instant.now()).zoneId
- the zone for which to calculate the schedule- Returns:
- Instant of the next occurrence.
-
validateSchedule
public abstract void validateSchedule()
-
compareTo
public int compareTo(Schedule schedule)
Compare twoSchedule
objects based on next occurrence.The next occurrences are calculated based on the current time.
- Specified by:
compareTo
in interfacejava.lang.Comparable<Schedule>
- Parameters:
schedule
- theSchedule
to be compared.- Returns:
- the value
0
if thisSchedule
next occurrence is equal to the argumentSchedule
next occurrence; a value less than0
if thisSchedule
next occurrence is before the argumentSchedule
next occurrence; and a value greater than0
if thisSchedule
next occurrence is after the argumentSchedule
next occurrence.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-