-
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 #238 from navikt/unit_type
Unit type
- Loading branch information
Showing
13 changed files
with
78 additions
and
19 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
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
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
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
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
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
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
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
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,38 @@ | ||
package no.nav.klage.kodeverk | ||
|
||
import jakarta.persistence.AttributeConverter | ||
import jakarta.persistence.Converter | ||
|
||
enum class TimeUnitType(override val id: String, override val navn: String, override val beskrivelse: String) : Kode { | ||
|
||
WEEKS("1", "WEEKS", "WEEKS"), | ||
MONTHS("2", "MONTHS", "MONTHS"), | ||
; | ||
|
||
override fun toString(): String { | ||
return "Type(id=$id, " + | ||
"navn=$navn)" | ||
} | ||
|
||
companion object { | ||
fun of(id: String): TimeUnitType { | ||
return entries.firstOrNull { it.id == id } | ||
?: throw IllegalArgumentException("No TimeUnitType with id $id exists") | ||
} | ||
|
||
fun fromNavn(navn: String): TimeUnitType { | ||
return entries.firstOrNull { it.navn == navn } | ||
?: throw IllegalArgumentException("No TimeUnitType with navn $navn exists") | ||
} | ||
} | ||
} | ||
|
||
@Converter | ||
class TimeUnitTypeConverter : AttributeConverter<TimeUnitType, String?> { | ||
|
||
override fun convertToDatabaseColumn(entity: TimeUnitType?): String? = | ||
entity?.id | ||
|
||
override fun convertToEntityAttribute(id: String?): TimeUnitType? = | ||
id?.let { TimeUnitType.of(it) } | ||
} |
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
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
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
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