package org.zalando.nakadi.client.java.model;

import java.util.List;

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

/**
 * Metadata for this Event. Contains commons fields for both Business and
 * DataChange Events. Most are enriched by Nakadi upon reception, but they in
 * general MIGHT be set by the client.
 */
public class EventMetadata {
    private final String eid;
    private final String eventTypeName;
    private final String occurredAt;
    private final String receivedAt;
    private final List<String> parentEids;
    private final String flowId;
    private final String partition;

    /**
     *
     * Metadata for this Event. Contains commons fields for both Business and
     * DataChange Events. Most are enriched by Nakadi upon reception, but they
     * in general MIGHT be set by the client.
     * 
     * @param eid
     *            Identifier of this Event. Clients are allowed to generate this
     *            and this SHOULD be guaranteed to be unique from the
     *            perspective of the producer. Consumers MIGHT use this value to
     *            assert uniqueness of reception of the Event.
     * @param eventTypeName
     *            The EventType of this Event. This is enriched by Nakadi on
     *            reception of the Event based on the endpoint where the
     *            Producer sent the Event to. If provided MUST match the
     *            endpoint. Failure to do so will cause rejection of the Event.
     * @param occurredAt
     *            Timestamp of creation of the Event generated by the producer.
     * @param receivedAt
     *            Timestamp of the reception of the Event by Nakadi. This is
     *            enriched upon reception of the Event. If set by the producer
     *            Event will be rejected.
     * @param parentEids
     *            Event identifier of the Event that caused the generation of
     *            this Event. Set by the producer.
     * @param flowId
     *            The flow-id of the producer of this Event. As this is usually
     *            a HTTP header, this is enriched from the header into the
     *            metadata by Nakadi to avoid clients having to explicitly copy
     *            this.
     * @param metadata
     *            This Metadata contains common fields unrelated to Nakadi
     *            logic. Should be mainly enriched by the Consumer.
     *
     */
    @JsonCreator
    public EventMetadata(
    		@JsonProperty("eid") String eid, 
    		@JsonProperty("event_type")String eventTypeName, 
    		@JsonProperty("occurred_at")String occurredAt, 
    		@JsonProperty("received_at")String receivedAt,
    		@JsonProperty("parent_eids")List<String> parentEids,
    		@JsonProperty("flow_id")String flowId,
    		@JsonProperty("partition")String partition) {
        super();
        this.eid = eid;
        this.eventTypeName = eventTypeName;
        this.occurredAt = occurredAt;
        this.receivedAt = receivedAt;
        this.parentEids = parentEids;
        this.flowId = flowId;
        this.partition = partition;
    }

    public String getEid() {
        return eid;
    }

    public String getEventTypeName() {
        return eventTypeName;
    }

    public String getOccurredAt() {
        return occurredAt;
    }

    public String getReceivedAt() {
        return receivedAt;
    }

    public List<String> getParentEids() {
        return parentEids;
    }

    public String getFlowId() {
        return flowId;
    }

    public String getPartition() {
        return partition;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((eid == null) ? 0 : eid.hashCode());
        result = prime * result + ((eventTypeName == null) ? 0 : eventTypeName.hashCode());
        result = prime * result + ((flowId == null) ? 0 : flowId.hashCode());
        result = prime * result + ((occurredAt == null) ? 0 : occurredAt.hashCode());
        result = prime * result + ((parentEids == null) ? 0 : parentEids.hashCode());
        result = prime * result + ((partition == null) ? 0 : partition.hashCode());
        result = prime * result + ((receivedAt == null) ? 0 : receivedAt.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        EventMetadata other = (EventMetadata) obj;
        if (eid == null) {
            if (other.eid != null)
                return false;
        } else if (!eid.equals(other.eid))
            return false;
        if (eventTypeName == null) {
            if (other.eventTypeName != null)
                return false;
        } else if (!eventTypeName.equals(other.eventTypeName))
            return false;
        if (flowId == null) {
            if (other.flowId != null)
                return false;
        } else if (!flowId.equals(other.flowId))
            return false;
        if (occurredAt == null) {
            if (other.occurredAt != null)
                return false;
        } else if (!occurredAt.equals(other.occurredAt))
            return false;
        if (parentEids == null) {
            if (other.parentEids != null)
                return false;
        } else if (!parentEids.equals(other.parentEids))
            return false;
        if (partition == null) {
            if (other.partition != null)
                return false;
        } else if (!partition.equals(other.partition))
            return false;
        if (receivedAt == null) {
            if (other.receivedAt != null)
                return false;
        } else if (!receivedAt.equals(other.receivedAt))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "EventMetadata [eid=" + eid + ", eventTypeName=" + eventTypeName + ", occurredAt=" + occurredAt + ", receivedAt=" + receivedAt + ", parentEids=" + parentEids + ", flowId=" + flowId
                + ", partition=" + partition + "]";
    }

    
    
}

@@ -3192,32 +3192,64 @@
 urn eid;%0A    %7D%0A%0A
+    @JsonProperty(%22event_type%22)%0A
     public Strin

Generate the JSON property event_type instead of event_type_name. Fixes #108