Class Schedule

    • Field Detail

      • SMALLEST_SCHEDULE_IN_SECONDS

        public static final int SMALLEST_SCHEDULE_IN_SECONDS
        See Also:
        Constant Field Values
    • Constructor Detail

      • Schedule

        public Schedule()
    • Method Detail

      • next

        public Instant next​(Instant createdAt,
                            ZoneId zoneId)
        Calculates the next occurrence based on the creation time and the current time.
        Parameters:
        createdAt - Instant object when the schedule was first created
        zoneId - the zone for which to calculate the schedule
        Returns:
        Instant of the next occurrence.
      • next

        @VisibleFor("testing")
        public abstract Instant next​(Instant createdAtInstant,
                                     Instant currentInstant,
                                     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 created
        currentInstant - 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 two Schedule objects based on next occurrence.

        The next occurrences are calculated based on the current time.

        Specified by:
        compareTo in interface Comparable<Schedule>
        Parameters:
        schedule - the Schedule to be compared.
        Returns:
        the value 0 if this Schedule next occurrence is equal to the argument Schedule next occurrence; a value less than 0 if this Schedule next occurrence is before the argument Schedule next occurrence; and a value greater than 0 if this Schedule next occurrence is after the argument Schedule next occurrence.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object