package vn.azteam.tpf.service.dto;

import java.time.Instant;
import java.io.Serializable;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * A DTO for the TBProductBlockDetails entity.
 */

public class TBProductBlockDetailsDTO implements Serializable {

    private Long id;

    private Double quantity;

    private Double importQuantity;

    private String code;

    private Instant harvestDate;

    private Instant expDate;

    private Integer productLevel;

    private Long tbProductUnitId;

    private String tbProductUnitName;

    private Long tbCropId;

    private String tbCropCode;

    private String tbSuppliesName;

    private Long tbEntityId;

    private String tbEntityName;

    private String description;

    public TBProductBlockDetailsDTO() {

    }

    public TBProductBlockDetailsDTO(javax.persistence.Tuple tuple) {
        if(tuple.get("id") != null) {
            this.id = ((BigInteger) tuple.get("id")).longValue();
        }
        if(tuple.get("quantity") != null) {
            this.quantity = ((Double) tuple.get("quantity")).doubleValue();
        }
        if (tuple.get("importQuantity") != null) {
            this.importQuantity = ((Double) tuple.get("importQuantity"));
        }
        if (tuple.get("code") != null) {
            this.code = tuple.get("code").toString();
        }
        if (tuple.get("description") != null) {
            this.description = tuple.get("description").toString();
        }

        if (tuple.get("harvestDate") != null) {
            this.harvestDate = ((Timestamp) tuple.get("harvestDate")).toInstant();
        }

        if (tuple.get("expDate") != null) {
            this.expDate = ((Timestamp) tuple.get("expDate")).toInstant();
        }

        if (tuple.get("productLevel") != null) {
            this.productLevel = ((Integer) tuple.get("productLevel")).intValue();
        }

        if (tuple.get("tbProductUnitId") != null) {
            this.tbProductUnitId = ((BigInteger) tuple.get("tbProductUnitId")).longValue();
        }

        if (tuple.get("tbProductUnitName") != null) {
            this.tbProductUnitName = tuple.get("tbProductUnitName").toString();
        }

        if (tuple.get("tbCropId") != null) {
            this.tbCropId = ((BigInteger) tuple.get("tbCropId")).longValue();
        }

        if (tuple.get("tbCropCode") != null) {
            this.tbCropCode = tuple.get("tbCropCode").toString();
        }

        if (tuple.get("tbSuppliesName") != null) {
            this.tbSuppliesName = tuple.get("tbSuppliesName").toString();
        }

        if (tuple.get("tbEntityId") != null) {
            this.tbEntityId = ((BigInteger) tuple.get("tbEntityId")).longValue();
        }

        if (tuple.get("tbEntityName") != null) {
            this.tbEntityName = tuple.get("tbEntityName").toString();
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Double getQuantity() {
        return quantity;
    }

    public Double getImportQuantity() {
        return importQuantity;
    }

    public void setImportQuantity(Double importQuantity) {
        this.importQuantity = importQuantity;
    }

    public void setQuantity(Double quantity) {
        this.quantity = quantity;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Instant getHarvestDate() {
        return harvestDate;
    }

    public void setHarvestDate(Instant harvestDate) {
        this.harvestDate = harvestDate;
    }

    public Instant getExpDate() {
        return expDate;
    }

    public void setExpDate(Instant expDate) {
        this.expDate = expDate;
    }

    public Integer getProductLevel() {
        return productLevel;
    }

    public void setProductLevel(Integer productLevel) {
        this.productLevel = productLevel;
    }

    public Long getTbProductUnitId() {
        return tbProductUnitId;
    }

    public void setTbProductUnitId(Long tBProductUnitId) {
        this.tbProductUnitId = tBProductUnitId;
    }

    public Long getTbCropId() {
        return tbCropId;
    }

    public void setTbCropId(Long tbCropId) {
        this.tbCropId = tbCropId;
    }

    public Long getTbEntityId() {
        return tbEntityId;
    }

    public void setTbEntityId(Long tbEntityId) {
        this.tbEntityId = tbEntityId;
    }

    public String getTbEntityName() {
        return tbEntityName;
    }

    public void setTbEntityName(String tbEntityName) {
        this.tbEntityName = tbEntityName;
    }

    public String getTbSuppliesName() {
        return tbSuppliesName;
    }

    public void setTbSuppliesName(String tbSuppliesName) {
        this.tbSuppliesName = tbSuppliesName;
    }

    public String getTbCropCode() {
        return tbCropCode;
    }

    public void setTbCropCode(String tbCropCode) {
        this.tbCropCode = tbCropCode;
    }

    public String getTbProductUnitName() {
        return tbProductUnitName;
    }

    public void setTbProductUnitName(String tbProductUnitName) {
        this.tbProductUnitName = tbProductUnitName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

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

        TBProductBlockDetailsDTO tBProductBlockDetailsDTO = (TBProductBlockDetailsDTO) o;
        if (tBProductBlockDetailsDTO.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), tBProductBlockDetailsDTO.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "TBProductBlockDetailsDTO{" +
            "id=" + getId() +
            ", quantity=" + getQuantity() +
            ", code='" + getCode() + "'" +
            ", harvestDate='" + getHarvestDate() + "'" +
            ", expDate='" + getExpDate() + "'" +
            ", productLevel=" + getProductLevel() +
            ", tbProductUnit=" + getTbProductUnitId() +
            "}";
    }
}
