From 126a364d8343fb2da531531395ba7705fb0209d4 Mon Sep 17 00:00:00 2001 From: Andrea Giulianelli Date: Tue, 16 May 2023 10:52:51 +0200 Subject: [PATCH] refactor: make states a data class --- src/main/kotlin/entity/process/SurgicalProcess.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/entity/process/SurgicalProcess.kt b/src/main/kotlin/entity/process/SurgicalProcess.kt index 203dd16..a715672 100644 --- a/src/main/kotlin/entity/process/SurgicalProcess.kt +++ b/src/main/kotlin/entity/process/SurgicalProcess.kt @@ -57,7 +57,7 @@ data class SurgicalProcessID(val value: String) { * Each state is in a [currentStep] that must be supported. */ sealed class SurgicalProcessState( - val currentStep: SurgicalProcessStep? = null, + private val currentStep: SurgicalProcessStep? = null, supportedSteps: Set = setOf(), ) { @@ -65,14 +65,14 @@ sealed class SurgicalProcessState( require(currentStep == null || currentStep in supportedSteps) } - /** Pre-surgery state. */ - class PreSurgery(currentStep: SurgicalProcessStep) : SurgicalProcessState( + /** Pre-surgery state with the [currentStep]. */ + data class PreSurgery(val currentStep: SurgicalProcessStep) : SurgicalProcessState( currentStep, setOf(SurgicalProcessStep.PATIENT_IN_PREPARATION), ) - /** Surgery state. */ - class Surgery(currentStep: SurgicalProcessStep) : SurgicalProcessState( + /** Surgery state with the [currentStep]. */ + data class Surgery(val currentStep: SurgicalProcessStep) : SurgicalProcessState( currentStep, setOf( SurgicalProcessStep.PATIENT_ON_OPERATING_TABLE, @@ -82,8 +82,8 @@ sealed class SurgicalProcessState( ), ) - /** Post-surgery state. */ - class PostSurgery(currentStep: SurgicalProcessStep) : SurgicalProcessState( + /** Post-surgery state with the [currentStep]. */ + data class PostSurgery(val currentStep: SurgicalProcessStep) : SurgicalProcessState( currentStep, setOf(SurgicalProcessStep.PATIENT_UNDER_OBSERVATION), )