feature/creation #2

Merged
zobrock merged 7 commits from feature/creation into main 2025-10-19 15:41:14 +02:00
1 changed files with 19 additions and 0 deletions
Showing only changes of commit 6ee21f0e87 - Show all commits

View File

@ -0,0 +1,19 @@
package org.octopus.internal.db.converters
import jakarta.persistence.AttributeConverter
import jakarta.persistence.Converter
import java.time.Month
@Converter
class MonthListConverter : AttributeConverter<List<Month>, String> {
override fun convertToDatabaseColumn(attribute: List<Month>?): String? {
return attribute?.joinToString(separator = ",") { it.name }
}
override fun convertToEntityAttribute(dbData: String?): List<Month>? {
return dbData?.split(",")
?.filter { it.isNotBlank() }
?.mapNotNull { runCatching { Month.valueOf(it.trim()) }.getOrNull() }
}
}