DealExposureEvent.java

package com.tradecloud.domain.model.events;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "DealExposureEvent")
@Access(AccessType.FIELD)
@NamedQuery(query = " select ce from DealExposureEvent ce where ce.consumerTag = :consumerTag", name = "findAllDealExposureEventForUser")
public class DealExposureEvent extends Event {

    public static enum DealExposureEventType {
        DEAL_LINKED, DEAL_UNLINKED, DEAL_UPDATE;
    }

    private String forexGroupCode;

    private String shipmentReference;

    private String invoiceReference;

    @Override
    public Class getInstanceClass() {
        return DealExposureEvent.class;
    }

    public DealExposureEvent() {

    }

    public DealExposureEvent(String reference, Date timestamp, String eventType, String consumerTag, String forexGroupCode,
                             String shipmentReference, String invoiceReference) {
        super(reference, timestamp, null, eventType, consumerTag);
        this.forexGroupCode = forexGroupCode;
        this.shipmentReference = shipmentReference;
        this.invoiceReference = invoiceReference;
    }

    public String getForexGroupCode() {
        return forexGroupCode;
    }

    public String getShipmentReference() {
        return shipmentReference;
    }

    public String getInvoiceReference() {
        return invoiceReference;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        DealExposureEvent that = (DealExposureEvent) o;

        return new EqualsBuilder()
                .append(getReference(), that.getReference())
                .append(forexGroupCode, that.forexGroupCode)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .append(getReference())
                .append(forexGroupCode)
                .toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("reference", reference)
                .append("forexGroupCode", forexGroupCode)
                .append("eventType", eventType)
                .append("id", id)
                .toString();
    }
}