https://kotlinlang.org logo
#codingconventions
Title
# codingconventions
a

Asaf Peleg

09/22/2023, 2:28 AM
I'm using this class for Kafka deserialization and I'd like to wrap/extend it in some clean way so that result implements
Deserializer<GenericRecord>
instead of
Any
What approaches can I use for that?
To start with I just created a wrapper class of sorts that implements
Deserializer<GenericRecord>
and instantiates a
GlueSchemaRegistryKafkaDeserializer
and all the override functions just call it with a case to
GenericRecord
when it deserializes
p

pdvrieze

09/22/2023, 1:26 PM
I had a look, that particular implementation is to deserialize arbitrary data/types. If you want a type specific wrapper what you'd need to do is have that wrapper forward the request, and then cast the result to the actual type. Alternatively you could do explicit error handling (wrong type)