I want to initialize KafkaConsumer
generic types using classes loaded with reflection. The classes will be generated via avro-tools
and will be extending SpecificRecordBase
class. I know, I can use wildcards and do something like -
KafkaConsumer<? extends SpecificRecordBase, ? extends SpecificRecordBase> consumer = new KafkaConsumer<>(properties);
However, I am looking for something like -
Class keyClass = Class.forName("com.test.KeyClass");
Class valueClass = Class.forName("com.test.ValueClass");
KafkaConsumer<keyClass, valueClass> consumer = new KafkaConsumer<>(properties);
Any pointers would be appreciated. Thanks.
Aucun commentaire:
Enregistrer un commentaire