Skip to content

Commit

Permalink
Merge pull request #127 from navikt/flowstate
Browse files Browse the repository at this point in the history
Added flowState to unite medunderskriverFlyt and rolState.
  • Loading branch information
flexable777 authored Aug 30, 2023
2 parents 6dd338b + e5879dd commit 56cb166
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/kotlin/no/nav/klage/kodeverk/FlowState.kt
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) }
}

0 comments on commit 56cb166

Please sign in to comment.