Skip to content

Event model in Java

Fernando Benjamin edited this page May 18, 2016 · 13 revisions

The java client uses Jackson for serializing/deserializing json content, to use this default serialization logic you need to use the Jackson annotations on your Event model:

  • Annotate the constructor with the Jackson @JsonCreater.

  • Annotate each constructor parameter with @JsonProperty.


Create your Event Model
import org.zalando.nakadi.client.java.model.Event;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class MeetingsEvent implements Event {
    private final String date;
    private final String topic;

    @JsonCreator
    public MeetingsEvent(@JsonProperty("date") String date, 
                        @JsonProperty("topic") String topic) {
        this.date = date;
        this.topic = topic;
    }

    public String getDate() {
        return date;
    }

    public String getTopic() {
        return topic;
    }

}