Is it possible to write an Avro schema/IDL that will generate a Java class that either extends a base class or implements an interface?
It seems like the generated Java class extends the org.apache.avro.specific.SpecificRecordBase
. So, the implements might be the way to go. But, I don't know if this is possible.
I have seen examples with suggestions to define an explicit "type" field in each specific schema, with more of an association than inheritance semantics.
I use my base class heavily in my factory classes and other parts of the code with generics like <T extends BaseObject>
. Currently, I had it code generated from the JSON Schema, which supports inheritance.
Another side question: can you use IDL to define just records without the protocol definition? I think the answer is no because the compiler complains about the missing protocol keyword.
Help appreciated! Thanks.