NSCv3: simplify enums

This commit is contained in:
Milos Kozak 2022-12-26 23:11:34 +01:00
parent c2e314bd42
commit 04e103848c
4 changed files with 7 additions and 54 deletions

View file

@ -18,12 +18,7 @@ fun NSBolus.toBolus(): Bolus =
)
fun NSBolus.BolusType?.toBolusType(): Bolus.Type =
when (this) {
NSBolus.BolusType.NORMAL -> Bolus.Type.NORMAL
NSBolus.BolusType.SMB -> Bolus.Type.SMB
NSBolus.BolusType.PRIMING -> Bolus.Type.PRIMING
null -> Bolus.Type.NORMAL
}
Bolus.Type.fromString(this?.name)
fun Bolus.toNSBolus(): NSBolus =
NSBolus(
@ -43,9 +38,4 @@ fun Bolus.toNSBolus(): NSBolus =
)
fun Bolus.Type?.toBolusType(): NSBolus.BolusType =
when (this) {
Bolus.Type.NORMAL -> NSBolus.BolusType.NORMAL
Bolus.Type.SMB -> NSBolus.BolusType.SMB
Bolus.Type.PRIMING -> NSBolus.BolusType.PRIMING
null -> NSBolus.BolusType.NORMAL
}
NSBolus.BolusType.fromString(this?.name)

View file

@ -15,11 +15,4 @@ fun NSOfflineEvent.toOfflineEvent(): OfflineEvent =
)
fun NSOfflineEvent.Reason?.toReason(): OfflineEvent.Reason =
when (this) {
NSOfflineEvent.Reason.DISCONNECT_PUMP -> OfflineEvent.Reason.DISCONNECT_PUMP
NSOfflineEvent.Reason.SUSPEND -> OfflineEvent.Reason.SUSPEND
NSOfflineEvent.Reason.DISABLE_LOOP -> OfflineEvent.Reason.DISABLE_LOOP
NSOfflineEvent.Reason.SUPER_BOLUS -> OfflineEvent.Reason.SUPER_BOLUS
NSOfflineEvent.Reason.OTHER -> OfflineEvent.Reason.OTHER
null -> OfflineEvent.Reason.OTHER
}
OfflineEvent.Reason.fromString(this?.name)

View file

@ -20,14 +20,7 @@ fun NSTemporaryBasal.toTemporaryBasal(): TemporaryBasal =
)
fun NSTemporaryBasal.Type?.toType(): TemporaryBasal.Type =
when (this) {
NSTemporaryBasal.Type.NORMAL -> TemporaryBasal.Type.NORMAL
NSTemporaryBasal.Type.EMULATED_PUMP_SUSPEND -> TemporaryBasal.Type.EMULATED_PUMP_SUSPEND
NSTemporaryBasal.Type.PUMP_SUSPEND -> TemporaryBasal.Type.PUMP_SUSPEND
NSTemporaryBasal.Type.SUPERBOLUS -> TemporaryBasal.Type.SUPERBOLUS
NSTemporaryBasal.Type.FAKE_EXTENDED -> TemporaryBasal.Type.FAKE_EXTENDED
null -> TemporaryBasal.Type.NORMAL
}
TemporaryBasal.Type.fromString(this?.name)
fun TemporaryBasal.toNSTemporaryBasal(profile: Profile): NSTemporaryBasal =
NSTemporaryBasal(
@ -49,11 +42,4 @@ fun TemporaryBasal.toNSTemporaryBasal(profile: Profile): NSTemporaryBasal =
)
fun TemporaryBasal.Type?.toType(): NSTemporaryBasal.Type =
when (this) {
TemporaryBasal.Type.NORMAL -> NSTemporaryBasal.Type.NORMAL
TemporaryBasal.Type.EMULATED_PUMP_SUSPEND -> NSTemporaryBasal.Type.EMULATED_PUMP_SUSPEND
TemporaryBasal.Type.PUMP_SUSPEND -> NSTemporaryBasal.Type.PUMP_SUSPEND
TemporaryBasal.Type.SUPERBOLUS -> NSTemporaryBasal.Type.SUPERBOLUS
TemporaryBasal.Type.FAKE_EXTENDED -> NSTemporaryBasal.Type.FAKE_EXTENDED
null -> NSTemporaryBasal.Type.NORMAL
}
NSTemporaryBasal.Type.fromString(this?.name)

View file

@ -19,15 +19,7 @@ fun NSTemporaryTarget.toTemporaryTarget(): TemporaryTarget =
)
fun NSTemporaryTarget.Reason?.toReason(): TemporaryTarget.Reason =
when (this) {
NSTemporaryTarget.Reason.CUSTOM -> TemporaryTarget.Reason.CUSTOM
NSTemporaryTarget.Reason.HYPOGLYCEMIA -> TemporaryTarget.Reason.HYPOGLYCEMIA
NSTemporaryTarget.Reason.ACTIVITY -> TemporaryTarget.Reason.ACTIVITY
NSTemporaryTarget.Reason.EATING_SOON -> TemporaryTarget.Reason.EATING_SOON
NSTemporaryTarget.Reason.AUTOMATION -> TemporaryTarget.Reason.AUTOMATION
NSTemporaryTarget.Reason.WEAR -> TemporaryTarget.Reason.WEAR
null -> TemporaryTarget.Reason.CUSTOM
}
TemporaryTarget.Reason.fromString(this?.text)
fun TemporaryTarget.toNSTemporaryTarget(): NSTemporaryTarget =
NSTemporaryTarget(
@ -48,12 +40,4 @@ fun TemporaryTarget.toNSTemporaryTarget(): NSTemporaryTarget =
)
fun TemporaryTarget.Reason?.toReason(): NSTemporaryTarget.Reason =
when (this) {
TemporaryTarget.Reason.CUSTOM -> NSTemporaryTarget.Reason.CUSTOM
TemporaryTarget.Reason.HYPOGLYCEMIA -> NSTemporaryTarget.Reason.HYPOGLYCEMIA
TemporaryTarget.Reason.ACTIVITY -> NSTemporaryTarget.Reason.ACTIVITY
TemporaryTarget.Reason.EATING_SOON -> NSTemporaryTarget.Reason.EATING_SOON
TemporaryTarget.Reason.AUTOMATION -> NSTemporaryTarget.Reason.AUTOMATION
TemporaryTarget.Reason.WEAR -> NSTemporaryTarget.Reason.WEAR
null -> NSTemporaryTarget.Reason.CUSTOM
}
NSTemporaryTarget.Reason.fromString(this?.text)