Remy Benza
01/16/2021, 12:19 PMMutableList<Pair<Pair<String, Boolean>, Triple<String, String, Boolean>>>
type with the kotlinx serialization lib without writing a custom type converter?Remy Benza
01/16/2021, 12:19 PMRemy Benza
01/16/2021, 12:20 PM.encodeToString()
won't work in this casenfrankel
01/16/2021, 2:04 PMRemy Benza
01/16/2021, 2:22 PMRemy Benza
01/16/2021, 2:26 PMjbnizet
01/16/2021, 4:34 PMMutableList<Pair<Pair<String, Boolean>, Triple<String, String, Boolean>>>
, or any code using it, there is absolutely no way of knowing what the list represents, what the pairs represent, what the strings and the booleans represent. Even with your example, it’s not quite easy to figure out. If you had a class WeeklySchedule
, containing a collection (list, or map) of Appointment
(I’m guessing here), containing a TimeInterval, and named boolean properties such as booked
or meetingPlanned
for example, all the code would be much easier to understand than things like list[2].first.second
. Instead you could have weeklyScheduled.get(TUESDAY).isBooked
. Your days shouldn’t be strings, but most probably a DayOfWeek enum instance. Your hours shouldn’t be strings but LocalTime instances. This would prevent you from storing incorrect values like “Satrday” or “25:62" in your objects.nanodeath
01/16/2021, 4:45 PMList<Period>
. that captures all the "true" values, and each Period is an intra-day timerange already.Remy Benza
01/16/2021, 6:12 PMRemy Benza
01/16/2021, 6:14 PMjbnizet
01/16/2021, 7:20 PMRemy Benza
01/16/2021, 7:35 PMRemy Benza
01/16/2021, 7:36 PMMatteo Mirk
01/18/2021, 11:44 AMRemy Benza
01/18/2021, 2:14 PMRemy Benza
01/18/2021, 2:15 PMMatteo Mirk
01/18/2021, 2:58 PMisSelected
and dayOfWeek
properties, and restructure your time frame as a Map<DayOfWeek, RuleDay>
: this way only the existing mappings are those selected
• in RuleDay
you could leave separated from/until time fields, or you could merge them in a ClosedRange<LocalTime>
having only one property that will provide you facilities to check inclusion and boundaries
• |--> a “full day” flag would be represented as a 0..23 rangeRemy Benza
01/18/2021, 3:01 PMMatteo Mirk
01/18/2021, 3:16 PM