I have classes which are automatically created from a JSON schema. In my Example one of these classes is called AvroPropertie
.
Declaring and initializing objects from this class looks like this:
AvroPropertie aPropertie = AvroPropertie.newBuilder()
.setName(properties.get("name").asText())
.setDate(properties.get("date").asText())
.build();
If the JSON schema differs the variables like name
and date
differ as well. There could be more, less or totally different ones. It's always only these setters and the build()
method at the end.
Is there a way to generate this code automatically? Maybe reflection?
More context: Is the ApacheAvro Serializing and deserializing with code generation.
Ty!
Aucun commentaire:
Enregistrer un commentaire