-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fjern overflødig strengverdi i enum for json-nøkler #796
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,33 +12,38 @@ object Pri { | |
const val TOPIC = "helsearbeidsgiver.pri" | ||
|
||
@Serializable(KeySerializer::class) | ||
enum class Key( | ||
override val str: String, | ||
) : IKey { | ||
enum class Key : IKey { | ||
// Predefinerte fra rapids-and-rivers-biblioteket | ||
BEHOV("@behov"), | ||
LØSNING("@løsning"), | ||
BEHOV, | ||
LOESNING, | ||
|
||
// Egendefinerte | ||
NOTIS("notis"), | ||
BOOMERANG("boomerang"), | ||
ORGNR("orgnr"), | ||
FNR("fnr"), | ||
FORESPOERSEL_ID("forespoerselId"), | ||
SPINN_INNTEKTSMELDING_ID("spinnInntektsmeldingId"), | ||
VEDTAKSPERIODE_ID_LISTE("vedtaksperiode_id_liste"), | ||
SKAL_HA_PAAMINNELSE("skal_ha_paaminnelse"), | ||
FORESPOERSEL("forespoersel"), | ||
BOOMERANG, | ||
FNR, | ||
FORESPOERSEL, | ||
FORESPOERSEL_ID, | ||
NOTIS, | ||
ORGNR, | ||
SKAL_HA_PAAMINNELSE, | ||
SPINN_INNTEKTSMELDING_ID, | ||
VEDTAKSPERIODE_ID_LISTE, | ||
; | ||
|
||
override fun toString(): String = str | ||
override fun toString(): String = | ||
when (this) { | ||
BEHOV -> "@behov" | ||
LOESNING -> "@løsning" | ||
FORESPOERSEL_ID -> "forespoerselId" | ||
SPINN_INNTEKTSMELDING_ID -> "spinnInntektsmeldingId" | ||
else -> name.lowercase() | ||
Comment on lines
+34
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Luring den her 😅 Er det noen av disse vi klarer å bytte ut også, eller er camel case og krøllalfa-case så hardt innarbeidet på andre siden av Pri at det ikke er noe poeng? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vi kan egentlig endre alle. Vi må bare gidde å gjøre jobben. |
||
} | ||
|
||
companion object { | ||
internal fun fromJson(json: String): Key = | ||
internal fun fromJson(key: String): Key = | ||
Key.entries.firstOrNull { | ||
json == it.str | ||
key == it.toString() | ||
} | ||
?: throw IllegalArgumentException("Fant ingen Pri.Key med verdi som matchet '$json'.") | ||
?: throw IllegalArgumentException("Fant ingen Pri.Key med verdi som matchet '$key'.") | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hva signaliserer alfakrøllen i nøklene egentlig? At det er rapids and rivers-nøkler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RR-nøklene bruker @-prefixen, og disse to er innarbeidede nøkler. Vi startet å bruke dem, men har siden den gang ikke hatt noe særlig forhold til den "standarden". Vi kan nok endre disse også, men det er noen funksjoner i bomlo-cli som støtter "@event_name" out of the box, som vi da må fikse litt på for at det skal fungere.