Skip to content

[REFACTOR] Replace hand-written fromString() on enums with enumValueOf (Phase 11) #441

@gaaliciA1990

Description

@gaaliciA1990

Context

Several enums in edifikana/shared have hand-written fromString() companion object methods with manual when blocks. Kotlin's built-in enumValueOf<T>(value) does the same thing (throws IllegalArgumentException on unknown values) with less code and no custom logic to maintain.

This pattern was adopted before enumValueOf was in use in this project. New enums (TaskStatus, TaskPriority, and future additions) will use enumValueOf directly — this issue tracks updating the existing ones.

Enums to refactor

  • EventLogEventTypeedifikana/shared/src/commonMain/kotlin/com/cramsan/edifikana/lib/model/EventLogEventType.kt
  • Any other enums in edifikana/shared/src/commonMain/kotlin/com/cramsan/edifikana/lib/model/ with a fromString() companion method

Change

Remove the companion object { fun fromString(...) } block and update all call sites to use enumValueOf<EnumType>(value) (or enumValueOf<EnumType>(value ?: "") where nullability is needed).

Notes

  • Verify all call sites before removing fromString() — search the back-end and front-end for usages
  • New enums added going forward should not include fromString()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions