catatumbo
catatumbo copied to clipboard
Support for @Constructor
@sai-pullabhotla Pulled from #48: Adding support for an annotation that will specify which constructor to use. Lets fields be final for immutability, generated in the constructor. Default constructor would be the empty constructor and using setters to populate the fields.
I'm not too experienced with annotations so I can't really be of much help here but the idea was something similar to Jackson's @JsonCreator
here, in specific the property-based creator.
My specific case is that I deserialize JSON into a POJO and store it into the Datastore using Catatumbo. Of course I would have to do the opposite as well.
@Entity
public class Person {
@Identifier(autoGenerated = false)
private final String name;
@JsonCreator
@CataConstructor
public Person(@JsonProperty("name") final String name) {
this.name = name;
}
}
The Entity mapper could then use whatever constructor is annotated with @CataConstructor
and create the POJO from the Datastore Entity.
Again, if I can help in any way, please let me know !