Transhipment.java

package com.tradecloud.domain.shipment;

import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.place.PlaceOfLoading;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Date;

/**
 * Transhipment.
 */
@Entity
@Component(value = "transhipment")
@Table(name = "transhipment")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Transhipment")
public class Transhipment extends PersistenceBase implements Serializable {

    private static final long serialVersionUID = 1L;

    @OneToOne
    private Shipment shipment;

    private String voyageNumber;
    private String shippingLine;
    private String vesselCode;
    private String vesselName;
    @ManyToOne
    private PlaceOfLoading placeOfLoading;
    @ManyToOne
    private PlaceOfLoading placeOfLoadingTo;

    private Date estimatedDepartureDate;
    private Date actualDateOfDeparture;

    @Column(name = "estArrDateAtTSPort")
    private Date estimatedArrivalDateAtTranshipmentPort;
    @Column(name = "actArrDateAtTSPort")
    private Date actualArrivalDateAtTransshipmentPort;

    @Column(name = "estDateOfDepFromTSPort")
    private Date estimateDateOfDepartureFromTransshipmentPort;
    @Column(name = "actDateOfDepFromTSPort")
    private Date actualDateOfDepartureFromTransshipmentPort;

    public Transhipment() {
    }

    public Transhipment(Shipment shipment) {
        this.shipment = shipment;
    }

    public Transhipment(Shipment shipment, String voyageNumber, String shippingLine, String vesselCode, String vesselName,
                        PlaceOfLoading placeOfLoading, PlaceOfLoading placeOfLoadingTo, Date estimatedDepartureDate, Date actualDateOfDeparture) {
        this.shipment = shipment;
        this.voyageNumber = voyageNumber;
        this.shippingLine = shippingLine;
        this.vesselCode = vesselCode;
        this.vesselName = vesselName;
        this.placeOfLoading = placeOfLoading;
        this.placeOfLoadingTo = placeOfLoadingTo;
        this.estimatedDepartureDate = estimatedDepartureDate;
        this.actualDateOfDeparture = actualDateOfDeparture;
    }

    public Transhipment(Shipment shipment, String voyageNumber, String shippingLine, String vesselCode, String vesselName,
                        PlaceOfLoading placeOfLoading, PlaceOfLoading placeOfLoadingTo, Date estimatedDepartureDate, Date actualDateOfDeparture,
                        Date estimatedArrivalDateAtTranshipmentPort, Date actualArrivalDateAtTransshipmentPort) {
        this.shipment = shipment;
        this.voyageNumber = voyageNumber;
        this.shippingLine = shippingLine;
        this.vesselCode = vesselCode;
        this.vesselName = vesselName;
        this.placeOfLoading = placeOfLoading;
        this.placeOfLoadingTo = placeOfLoadingTo;
        this.estimatedDepartureDate = estimatedDepartureDate;
        this.actualDateOfDeparture = actualDateOfDeparture;
        this.estimatedArrivalDateAtTranshipmentPort = estimatedArrivalDateAtTranshipmentPort;
        this.actualArrivalDateAtTransshipmentPort = actualArrivalDateAtTransshipmentPort;
    }

    public Shipment getShipment() {
        return shipment;
    }

    public void setShipment(Shipment shipment) {
        this.shipment = shipment;
    }

    public String getVoyageNumber() {
        return voyageNumber;
    }

    public void setVoyageNumber(String voyageNumber) {
        this.voyageNumber = voyageNumber;
    }

    public String getShippingLine() {
        return shippingLine;
    }

    public void setShippingLine(String shippingLine) {
        this.shippingLine = shippingLine;
    }

    public String getVesselCode() {
        return vesselCode;
    }

    public void setVesselCode(String vesselCode) {
        this.vesselCode = vesselCode;
    }

    public String getVesselName() {
        return vesselName;
    }

    public void setVesselName(String vesselName) {
        this.vesselName = vesselName;
    }

    public PlaceOfLoading getPlaceOfLoading() {
        return placeOfLoading;
    }

    public void setPlaceOfLoading(PlaceOfLoading placeOfLoading) {
        this.placeOfLoading = placeOfLoading;
    }

    public PlaceOfLoading getPlaceOfLoadingTo() {
        return placeOfLoadingTo;
    }

    public void setPlaceOfLoadingTo(PlaceOfLoading placeOfLoadingTo) {
        this.placeOfLoadingTo = placeOfLoadingTo;
    }

    public Date getEstimatedDepartureDate() {
        return estimatedDepartureDate;
    }

    public void setEstimatedDepartureDate(Date estimatedDepartureDate) {
        this.estimatedDepartureDate = estimatedDepartureDate;
    }

    public Date getActualDateOfDeparture() {
        return actualDateOfDeparture;
    }

    public void setActualDateOfDeparture(Date actualDateOfDeparture) {
        this.actualDateOfDeparture = actualDateOfDeparture;
    }

    public Date getEstimatedArrivalDateAtTranshipmentPort() {
        return estimatedArrivalDateAtTranshipmentPort;
    }

    public void setEstimatedArrivalDateAtTranshipmentPort(Date estimatedArrivalDateAtTranshipmentPort) {
        this.estimatedArrivalDateAtTranshipmentPort = estimatedArrivalDateAtTranshipmentPort;
    }

    public Date getActualArrivalDateAtTransshipmentPort() {
        return actualArrivalDateAtTransshipmentPort;
    }

    public void setActualArrivalDateAtTransshipmentPort(Date actualArrivalDateAtTransshipmentPort) {
        this.actualArrivalDateAtTransshipmentPort = actualArrivalDateAtTransshipmentPort;
    }

    public Date getEstimateDateOfDepartureFromTransshipmentPort() {
        return estimateDateOfDepartureFromTransshipmentPort;
    }

    public void setEstimateDateOfDepartureFromTransshipmentPort(Date estimateDateOfDepartureFromTransshipmentPort) {
        this.estimateDateOfDepartureFromTransshipmentPort = estimateDateOfDepartureFromTransshipmentPort;
    }

    public Date getActualDateOfDepartureFromTransshipmentPort() {
        return actualDateOfDepartureFromTransshipmentPort;
    }

    public void setActualDateOfDepartureFromTransshipmentPort(Date actualDateOfDepartureFromTransshipmentPort) {
        this.actualDateOfDepartureFromTransshipmentPort = actualDateOfDepartureFromTransshipmentPort;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Transhipment)) {
            return false;
        }
        Transhipment other = (Transhipment) obj;

        return new EqualsBuilder().append(shipment, other.getShipment()).append(shippingLine, other.getShippingLine())
                .append(placeOfLoading, other.getPlaceOfLoading())
                .append(placeOfLoadingTo, other.getPlaceOfLoadingTo()).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(shipment).append(placeOfLoading).append(placeOfLoadingTo).append(shippingLine).toHashCode();
    }
}