I'm implementing this <interface> (see <IndexRecor...
# server
a
I'm implementing this interface (see IndexRecord ) which is a container for a decoded Avro object. It feels like the natural way to represent the record is a data class but I'm getting hung up on the fact that deserializer wants to instantiate my record and iteratively call
put
on each field. Since my data class would need an empty constructor I'd have to set defaults or make all of my fields optional, but neither seems ideal. Is there some trick or alternative to data classes that I could use or should I just be using a plain old class for this instead?
s
Not sure how the deserializer you're using works, but if it uses reflection underneath to instantiate empty object instance I would check if
no-arg
compiler plugin wouldn't do the trick for you (it would allow you to stick with data classes): https://kotlinlang.org/docs/no-arg-plugin.html
a
it doesn't use reflection it just does
object.put(key, value)
where put argument types are
(String, Object)