Skip to content

Marshaling Annotations #9

@teddziuba

Description

@teddziuba

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;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions