package it.integry.integrywmsnative.core.model;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import it.integry.integrywmsnative.core.utility.UtilityDate;

public class FiltroOrdineDTO {

    private String gestioneOrd;
    private String dataOrd;
    private String dataCons;
    private int numOrd;

    public String getGestioneOrd() {
        return gestioneOrd;
    }

    public FiltroOrdineDTO setGestioneOrd(String gestioneOrd) {
        this.gestioneOrd = gestioneOrd;
        return this;
    }

    public String getDataOrdS() {
        return dataOrd;
    }

    public Date getDataOrdD() {
        return UtilityDate.recognizeDateWithExceptionHandler(getDataOrdS());
    }

    public FiltroOrdineDTO setDataOrd(String dataOrd) {
        this.dataOrd = dataOrd;
        return this;
    }

    public FiltroOrdineDTO setDataOrd(Date dataOrd) {
        this.dataOrd = UtilityDate.formatDate(dataOrd, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
        return this;
    }

    public String getDataConsS() {
        return dataCons;
    }

    public Date getDataConsD() {
        return UtilityDate.recognizeDateWithExceptionHandler(getDataConsS());
    }

    public FiltroOrdineDTO setDataCons(String dataCons) {
        this.dataCons = dataCons;
        return this;
    }

    public FiltroOrdineDTO setDataCons(Date dataCons) {
        if(dataCons != null) {
            this.dataCons = UtilityDate.formatDate(dataCons, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
        }
        return this;
    }

    public int getNumOrd() {
        return numOrd;
    }

    public FiltroOrdineDTO setNumOrd(int numOrd) {
        this.numOrd = numOrd;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        FiltroOrdineDTO that = (FiltroOrdineDTO) o;

        if (getNumOrd() != that.getNumOrd()) return false;
        if (getGestioneOrd() != null ? !getGestioneOrd().equals(that.getGestioneOrd()) : that.getGestioneOrd() != null)
            return false;
        if (dataOrd != null ? !dataOrd.equals(that.dataOrd) : that.dataOrd != null) return false;
        return dataCons != null ? dataCons.equals(that.dataCons) : that.dataCons == null;
    }

    @Override
    public int hashCode() {
        int result = getGestioneOrd() != null ? getGestioneOrd().hashCode() : 0;
        result = 31 * result + (dataOrd != null ? dataOrd.hashCode() : 0);
        result = 31 * result + (dataCons != null ? dataCons.hashCode() : 0);
        result = 31 * result + getNumOrd();
        return result;
    }
}
