Skip to content

Commit

Permalink
refactor: make states a data class
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGiulianelli committed May 18, 2023
1 parent 9f5d037 commit 126a364
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/kotlin/entity/process/SurgicalProcess.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ 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<SurgicalProcessStep> = setOf(),
) {

init {
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,
Expand All @@ -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),
)
Expand Down

0 comments on commit 126a364

Please sign in to comment.