-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from navikt/flowstate
Added flowState to unite medunderskriverFlyt and rolState.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package no.nav.klage.kodeverk | ||
|
||
import jakarta.persistence.AttributeConverter | ||
import jakarta.persistence.Converter | ||
|
||
enum class FlowState(override val id: String, override val navn: String, override val beskrivelse: String) : | ||
Kode { | ||
NOT_SENT("1", "IKKE_SENDT", "Ikke sendt"), | ||
SENT("2", "OVERSENDT", "Oversendt"), | ||
RETURNED("3", "RETURNERT_TIL_SAKSBEHANDLER", "Returnert til saksbehandler") | ||
; | ||
|
||
override fun toString(): String { | ||
return "FlowState(id=$id, " + | ||
"navn=$navn)" | ||
} | ||
|
||
companion object { | ||
fun of(id: String): FlowState { | ||
return entries.firstOrNull { it.id == id } | ||
?: throw IllegalArgumentException("No FlowState with id $id exists") | ||
} | ||
|
||
fun fromNavn(navn: String?): FlowState { | ||
return entries.firstOrNull { it.navn == navn } | ||
?: throw IllegalArgumentException("No FlowState with navn $navn exists") | ||
} | ||
} | ||
} | ||
|
||
@Converter | ||
class FlowStateConverter : AttributeConverter<FlowState, String?> { | ||
|
||
override fun convertToDatabaseColumn(entity: FlowState?): String? = | ||
entity?.id | ||
|
||
override fun convertToEntityAttribute(id: String?): FlowState? = | ||
id?.let { FlowState.of(it) } | ||
} |