From 78096abeb8ca000e3480e98d300bec86350f9d13 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 5 Aug 2020 15:49:18 -0300 Subject: [wallet] support Timestamp with "never" --- .../src/main/java/net/taler/common/TimestampMixin.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'taler-kotlin-android/src/main') diff --git a/taler-kotlin-android/src/main/java/net/taler/common/TimestampMixin.kt b/taler-kotlin-android/src/main/java/net/taler/common/TimestampMixin.kt index 28dbe7f..6c1bebf 100644 --- a/taler-kotlin-android/src/main/java/net/taler/common/TimestampMixin.kt +++ b/taler-kotlin-android/src/main/java/net/taler/common/TimestampMixin.kt @@ -17,11 +17,23 @@ package net.taler.common import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.deser.std.StdDeserializer /** * Used to support Jackson serialization along with KotlinX. */ abstract class TimestampMixin( + @get:JsonDeserialize(using = NeverDeserializer::class) @get:JsonProperty("t_ms") val ms: Long ) + +class NeverDeserializer : StdDeserializer(Long::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Long { + return if (p.text == "never") -1 + else p.longValue + } +} -- cgit v1.2.3