package vn.azteam.tpf.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import org.springframework.data.elasticsearch.annotations.Document;
import java.io.Serializable;
import java.time.Instant;
import java.util.Objects;

/**
 * A TBProductBlockDetails.
 */
@Entity
@Table(name = "tb_product_block_details")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_tbproductblockdetails")
public class TBProductBlockDetails implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "quantity")
    private Double quantity;

    @Column(name = "code")
    private String code;

    @Column(name = "harvest_date")
    private Instant harvestDate;

    @Column(name = "exp_date")
    private Instant expDate;

    @Column(name = "product_level")
    private Integer productLevel;

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBProductUnit tbProductUnit;

    @JsonIgnore
    @ManyToOne
    @JsonIgnoreProperties("")
    private TBCrop tbCrop;

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBEntity tbEntity;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

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

    public Double getQuantity() {
        return quantity;
    }

    public TBProductBlockDetails quantity(Double quantity) {
        this.quantity = quantity;
        return this;
    }

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

    public String getCode() {
        return code;
    }

    public TBProductBlockDetails code(String code) {
        this.code = code;
        return this;
    }

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

    public Instant getHarvestDate() {
        return harvestDate;
    }

    public TBProductBlockDetails harvestDate(Instant harvestDate) {
        this.harvestDate = harvestDate;
        return this;
    }

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

    public Instant getExpDate() {
        return expDate;
    }

    public TBProductBlockDetails expDate(Instant expDate) {
        this.expDate = expDate;
        return this;
    }

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

    public Integer getProductLevel() {
        return productLevel;
    }

    public TBProductBlockDetails productLevel(Integer productLevel) {
        this.productLevel = productLevel;
        return this;
    }

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

    public TBProductUnit getTbProductUnit() {
        return tbProductUnit;
    }

    public TBProductBlockDetails tbProductUnit(TBProductUnit tBProductUnit) {
        this.tbProductUnit = tBProductUnit;
        return this;
    }

    public void setTbProductUnit(TBProductUnit tBProductUnit) {
        this.tbProductUnit = tBProductUnit;
    }

    public TBCrop getTbCrop() {
        return tbCrop;
    }

    public TBProductBlockDetails tbCrop(TBCrop tbCrop) {
        this.tbCrop = tbCrop;
        return this;
    }

    public void setTbCrop(TBCrop tbCrop) {
        this.tbCrop = tbCrop;
    }

    public TBEntity getTbEntity() {
        return tbEntity;
    }

    public TBProductBlockDetails tbWarehouse(TBEntity tbEntity) {
        this.tbEntity = tbEntity;
        return this;
    }

    public void setTbEntity(TBEntity tbEntity) {
        this.tbEntity = tbEntity;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

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

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

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