Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for @Constructor #49

Open
arthur-tse7 opened this issue Oct 27, 2016 · 0 comments
Open

Support for @Constructor #49

arthur-tse7 opened this issue Oct 27, 2016 · 0 comments

Comments

@arthur-tse7
Copy link

@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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant