@@ -8,21 +8,41 @@ import kotlinx.datetime.number
88
99/* *
1010 * A [Pulse] schedule that can be used with [schedulePulse] to define complex schedules.
11- *
12- * @constructor Creates a new PulseSchedule. Second values must be in range 0..59, minute values must be in range 0..59,
13- * hour values must be in range 0..23, and day of month values must be in range 1..31. This constructor also
14- * requires that seconds, minutes, hours, days of month, and months cannot be empty sets.
15- * @throws IllegalArgumentException if the constructor is called with any of our bounds value or an improperly empty set.
1611 */
1712@Poko
18- public class PulseSchedule (
19- public val atSeconds : Set <Int >,
20- public val atMinutes : Set <Int >,
21- public val atHours : Set <Int >,
22- public val onDaysOfMonth : Set <Int >,
23- public val inMonths : Set <Month >,
24- public val onDaysOfWeek : Set <DayOfWeek >,
13+ public class PulseSchedule internal constructor (
14+ public val atSeconds : List <Int >,
15+ public val atMinutes : List <Int >,
16+ public val atHours : List <Int >,
17+ public val onDaysOfMonth : List <Int >,
18+ public val inMonths : List <Month >,
19+ public val onDaysOfWeek : List <DayOfWeek >,
2520) {
21+
22+ /* *
23+ * Creates a new PulseSchedule. Second values must be in range 0..59, minute values must be in range 0..59,
24+ * hour values must be in range 0..23, and day of month values must be in range 1..31. This constructor also
25+ * requires that seconds, minutes, hours, days of month, and months cannot be empty sets.
26+ *
27+ * @throws IllegalArgumentException if the constructor is called with any of our bounds value or an improperly empty
28+ * set.
29+ */
30+ public constructor (
31+ atSeconds: Set <Int >,
32+ atMinutes: Set <Int >,
33+ atHours: Set <Int >,
34+ onDaysOfMonth: Set <Int >,
35+ inMonths: Set <Month >,
36+ onDaysOfWeek: Set <DayOfWeek >,
37+ ) : this (
38+ atSeconds = atSeconds.sorted(),
39+ atMinutes = atMinutes.sorted(),
40+ atHours = atHours.sorted(),
41+ onDaysOfMonth = onDaysOfMonth.sorted(),
42+ inMonths = inMonths.sorted(),
43+ onDaysOfWeek = onDaysOfWeek.sorted()
44+ )
45+
2646 init {
2747 require(! atSeconds.any { it !in 0 .. 59 }) { " Seconds has an out of bound value: $atSeconds " }
2848 require(atSeconds.isNotEmpty()) { " Seconds cannot be empty!" }
@@ -36,13 +56,6 @@ public class PulseSchedule(
3656 // Don't check if onDaysOfWeek is empty because an empty set is equivalent to the wildcard `*` value in cron
3757 // expressions.
3858 }
39-
40- internal val sortedSeconds = atSeconds.sorted()
41- internal val sortedMinutes = atMinutes.sorted()
42- internal val sortedHours = atHours.sorted()
43- internal val sortedDaysOfMonth = onDaysOfMonth.sorted()
44- internal val sortedMonths = inMonths.sorted()
45- internal val sortedDaysOfWeek = onDaysOfWeek.sorted()
4659}
4760
4861public class PulseScheduleBuilder internal constructor() {
0 commit comments