Skip to content

Commit

Permalink
Delegation doesn't work in this case
Browse files Browse the repository at this point in the history
  • Loading branch information
nsimonides committed Jan 11, 2025
1 parent 5043646 commit fc5b4f9
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ import kotlin.reflect.javaType
*/
@Component
@OptIn(ExperimentalStdlibApi::class)
class Serialization(private val objectMapper: ObjectMapper)
: Wirespec.Serialization<String>, Wirespec.ParamSerialization by DefaultParamSerialization() {
class Serialization(private val objectMapper: ObjectMapper) :
Wirespec.Serialization<String> {

private val defaultParamSerialization = DefaultParamSerialization()

override fun <T> serialize(t: T, kType: KType): String = objectMapper.writeValueAsString(t)

override fun <T> deserialize(raw: String, kType: KType): T = objectMapper
.constructType(kType.javaType)
.let { objectMapper.readValue(raw, it) }

override fun <T> serializeParam(value: T, kType: KType): List<String> =
defaultParamSerialization.serializeParam(value, kType)

override fun <T> deserializeParam(values: List<String>, kType: KType): T =
defaultParamSerialization.deserializeParam(values, kType)
}

0 comments on commit fc5b4f9

Please sign in to comment.