Skip to content

Commit 42991aa

Browse files
committed
simplify UuidDeserializer. Technically lessens the compatibility with older configs but everyone should already be updated to the new format now
1 parent eca33b8 commit 42991aa

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,5 @@ object UuidSerializer : Serializer<UUID>(UUID::class.java), Stringifiable<UUID>
3737
}
3838

3939
object UuidDeserializer : Deserializer<UUID>(UUID::class.java) {
40-
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UUID {
41-
val jsonNode = mapper.readTree(p)
42-
43-
val rawId = when {
44-
jsonNode.isString -> jsonNode.stringValue()
45-
jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").stringValue()
46-
else -> throw IllegalStateException("Cannot deserialize UUID from: $jsonNode")
47-
}
48-
49-
val parsedId = if (rawId.length == 32)
50-
rawId.replace(Regex("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"), "$1-$2-$3-$4-$5")
51-
else rawId
52-
53-
return UUID.fromString(parsedId)
54-
}
40+
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UUID = UUID.fromString(p.string)
5541
}

0 commit comments

Comments
 (0)