CronDateTimeScheduler adding

This commit is contained in:
InsanusMokrassar 2020-12-06 01:44:24 +06:00
parent 3162780447
commit 4995a34c1a
2 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -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<CronDateTime>
) : KronScheduler {
/**
@ -35,6 +35,17 @@ internal data class CronDateTimeScheduler internal constructor(
* [kronDateTimeSchedulers] included
*/
@Suppress("NOTHING_TO_INLINE")
internal inline fun merge(kronDateTimeSchedulers: List<CronDateTimeScheduler>) = CronDateTimeScheduler(
fun merge(kronDateTimeSchedulers: List<CronDateTimeScheduler>) = 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)