-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathInterDaySchedules.kt
31 lines (25 loc) · 993 Bytes
/
InterDaySchedules.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package kaist.iclab.abclogger.structure.survey
import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
sealed class InterDaySchedule(val type: Type){
enum class Type {
DATE,
DAY_OF_WEEK,
DAILY
}
companion object {
val Factory: PolymorphicJsonAdapterFactory<InterDaySchedule> = PolymorphicJsonAdapterFactory.of(InterDaySchedule::class.java, "type")
.withSubtype(DateSchedule::class.java, Type.DATE.name)
.withSubtype(DayOfWeekSchedule::class.java, Type.DAY_OF_WEEK.name)
.withSubtype(DailySchedule::class.java, Type.DAILY.name)
.withDefaultValue(DailySchedule())
}
}
data class DateSchedule(
val dates: List<LocalDate> = listOf()
) : InterDaySchedule(Type.DATE)
data class DayOfWeekSchedule(
val daysOfWeek: List<DayOfWeek> = listOf()
) : InterDaySchedule(Type.DAY_OF_WEEK)
class DailySchedule(
val exceptDates: List<LocalDate> = listOf()
) : InterDaySchedule(Type.DAILY)