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

Marshaling Annotations #9

Open
teddziuba opened this issue Sep 4, 2014 · 1 comment
Open

Marshaling Annotations #9

teddziuba opened this issue Sep 4, 2014 · 1 comment

Comments

@teddziuba
Copy link

It would be helpful to have annotations to mark up POJOs for Transit, and an the associated Reader/Writer implementations, in the style of Jackson Annotations.

I've been reading and writing POJOs with Transit with runtime reflection on the getters and setters (using commons beanutils), but that solution isn't as flexible when it comes to things overriding the introspected name of a field, and overriding the class's Transit tag.

This is the kind of construct I am thinking of:

@TransitTagged("com.example.SamplePojo")
public class SamplePojo {

    private String name = "John";
    private int age = 21;
    private String nonExposedField = "...";

    @TransitField("person-name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    // no annotation, default to reflection
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

    @TransitIgnore
    public String getNonExposedField() {
      return this.nonExposedField;
    }
}
@henryw374
Copy link

I'm thinking about a similar use case: Transition from jackson default serialization to transit.

For serializing stuff between java programs, jackson is really easy relative to transit. in writing pojos, you've already declared what type you want things to be and without any further coding jackson does a pretty good job. Especially with addons like jsr310 for example, all your specific time related is preserved.

if you're a non-jvm/java consumer of services doing this though, the type info in the pojo is lost except for strings and some number types.

So I'm thinking a transit module for jackson would be a good solution to easily transition json-producing java services.

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

2 participants