diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6325b..c6ae625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * Versions: * `Coroutines`: `1.4.1` -> `1.4.2` * `Klock`: `2.0.0` -> `2.0.1` +* `CronDateTimeScheduler` now is public +* New functions for `CronDateTimeScheduler` * Add `CollectionKronScheduler`. It will give opportunity to unite several schedulers in one ## 0.4.0 diff --git a/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt b/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt index 5d83a3c..db6873a 100644 --- a/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt +++ b/src/commonMain/kotlin/dev/inmo/krontab/internal/CronDateTimeScheduler.kt @@ -17,7 +17,7 @@ import dev.inmo.krontab.anyCronDateTime * @see dev.inmo.krontab.builder.buildSchedule * @see dev.inmo.krontab.builder.SchedulerBuilder */ -internal data class CronDateTimeScheduler internal constructor( +data class CronDateTimeScheduler internal constructor( internal val cronDateTimes: List ) : KronScheduler { /** @@ -35,6 +35,17 @@ internal data class CronDateTimeScheduler internal constructor( * [kronDateTimeSchedulers] included */ @Suppress("NOTHING_TO_INLINE") -internal inline fun merge(kronDateTimeSchedulers: List) = CronDateTimeScheduler( +fun merge(kronDateTimeSchedulers: List) = CronDateTimeScheduler( kronDateTimeSchedulers.flatMap { it.cronDateTimes }.distinct() ) + +/** + * @return Vararg shortcyut for [merge] + */ +@Suppress("NOTHING_TO_INLINE") +inline fun merge(vararg kronDateTimeSchedulers: CronDateTimeScheduler) = merge(kronDateTimeSchedulers.toList()) +/** + * Use [merge] operation to internalcreate new [CronDateTimeScheduler] with all [CronDateTimeScheduler.cronDateTimes] + */ +@Suppress("NOTHING_TO_INLINE") +inline fun CronDateTimeScheduler.plus(other: CronDateTimeScheduler) = merge(this, other)