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.HashSet;
import java.util.Set;
import java.util.Objects;

/**
 * A TBSupplies.
 */
@Entity
@Table(name = "tb_supplies")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_tbsupplies")
public class TBSupplies implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

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

    @Column(name = "jhi_use")
    private String use;

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

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

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

    @Column(name = "quarantine_period")
    private Integer quarantinePeriod;

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

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

    @Column(name = "jhi_size")
    private Double jhiSize;

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

    @Column(name = "created_date")
    private Instant createdDate;

    @Column(name = "modified_date")
    private Instant modifiedDate;

    @Column(name = "deleted_date")
    private Instant deletedDate;

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBSuppliesType tbSuppliesType;


    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "created_by")
    private TBDetailUser createdBy;

    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "modified_by")
    private TBDetailUser modifiedBy;

    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "deleted_by")
    private TBDetailUser deletedBy;

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBCustomer tbCustomer;

    @ManyToMany(mappedBy = "tbSupplies")
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    @JsonIgnore
    private Set<TBGuideline> tbGuidelines = new HashSet<>();

    // 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 String getName() {
        return name;
    }

    public TBSupplies name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIngredient() {
        return ingredient;
    }

    public TBSupplies ingredient(String ingredient) {
        this.ingredient = ingredient;
        return this;
    }

    public void setIngredient(String ingredient) {
        this.ingredient = ingredient;
    }

    public String getUse() {
        return use;
    }

    public TBSupplies use(String use) {
        this.use = use;
        return this;
    }

    public void setUse(String use) {
        this.use = use;
    }

    public String getSku() {
        return sku;
    }

    public TBSupplies sku(String sku) {
        this.sku = sku;
        return this;
    }

    public void setSku(String sku) {
        this.sku = sku;
    }



    public String getDescription() {
        return description;
    }

    public TBSupplies description(String description) {
        this.description = description;
        return this;
    }

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


    public String getManufacturer() {
        return manufacturer;
    }

    public TBSupplies manufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
        return this;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public Integer getQuarantinePeriod() {
        return quarantinePeriod;
    }

    public TBSupplies quarantinePeriod(Integer quarantinePeriod) {
        this.quarantinePeriod = quarantinePeriod;
        return this;
    }

    public void setQuarantinePeriod(Integer quarantinePeriod) {
        this.quarantinePeriod = quarantinePeriod;
    }

    public String getDosage() {
        return dosage;
    }

    public TBSupplies dosage(String dosage) {
        this.dosage = dosage;
        return this;
    }

    public void setDosage(String dosage) {
        this.dosage = dosage;
    }

    public String getPackaging() {
        return packaging;
    }

    public TBSupplies packaging(String packaging) {
        this.packaging = packaging;
        return this;
    }

    public void setPackaging(String packaging) {
        this.packaging = packaging;
    }

    public Double getJhiSize() {
        return jhiSize;
    }

    public TBSupplies jhiSize(Double jhiSize) {
        this.jhiSize = jhiSize;
        return this;
    }

    public void setJhiSize(Double jhiSize) {
        this.jhiSize = jhiSize;
    }

    public String getUnit() {
        return unit;
    }

    public TBSupplies unit(String unit) {
        this.unit = unit;
        return this;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public Instant getCreatedDate() {
        return createdDate;
    }

    public TBSupplies createdDate(Instant createdDate) {
        this.createdDate = createdDate;
        return this;
    }

    public void setCreatedDate(Instant createdDate) {
        this.createdDate = createdDate;
    }

    public Instant getModifiedDate() {
        return modifiedDate;
    }

    public TBSupplies modifiedDate(Instant modifiedDate) {
        this.modifiedDate = modifiedDate;
        return this;
    }

    public void setModifiedDate(Instant modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public Instant getDeletedDate() {
        return deletedDate;
    }

    public TBSupplies deletedDate(Instant deletedDate) {
        this.deletedDate = deletedDate;
        return this;
    }

    public void setDeletedDate(Instant deletedDate) {
        this.deletedDate = deletedDate;
    }

    public TBSuppliesType getTbSuppliesType() {
        return tbSuppliesType;
    }

    public TBSupplies tbSuppliesType(TBSuppliesType tBSuppliesType) {
        this.tbSuppliesType = tBSuppliesType;
        return this;
    }

    public void setTbSuppliesType(TBSuppliesType tBSuppliesType) {
        this.tbSuppliesType = tBSuppliesType;
    }

    public TBDetailUser getCreatedBy() {
        return createdBy;
    }

    public TBSupplies createdBy(TBDetailUser tBDetailUser) {
        this.createdBy = tBDetailUser;
        return this;
    }

    public void setCreatedBy(TBDetailUser tBDetailUser) {
        this.createdBy = tBDetailUser;
    }

    public TBDetailUser getModifiedBy() {
        return modifiedBy;
    }

    public TBSupplies modifiedBy(TBDetailUser tBDetailUser) {
        this.modifiedBy = tBDetailUser;
        return this;
    }

    public void setModifiedBy(TBDetailUser tBDetailUser) {
        this.modifiedBy = tBDetailUser;
    }

    public TBDetailUser getDeletedBy() {
        return deletedBy;
    }

    public TBSupplies deletedBy(TBDetailUser tBDetailUser) {
        this.deletedBy = tBDetailUser;
        return this;
    }

    public void setDeletedBy(TBDetailUser tBDetailUser) {
        this.deletedBy = tBDetailUser;
    }

    public TBCustomer getTbCustomer() {
        return tbCustomer;
    }

    public TBSupplies tbCustomer(TBCustomer tBCustomer) {
        this.tbCustomer = tBCustomer;
        return this;
    }

    public void setTbCustomer(TBCustomer tBCustomer) {
        this.tbCustomer = tBCustomer;
    }

    public Set<TBGuideline> getTbGuidelines() {
        return tbGuidelines;
    }

    public TBSupplies tbGuidelines(Set<TBGuideline> tBGuidelines) {
        this.tbGuidelines = tBGuidelines;
        return this;
    }

    public TBSupplies addTbGuideline(TBGuideline tBGuideline) {
        this.tbGuidelines.add(tBGuideline);
        tBGuideline.getTbSupplies().add(this);
        return this;
    }

    public TBSupplies removeTbGuideline(TBGuideline tBGuideline) {
        this.tbGuidelines.remove(tBGuideline);
        tBGuideline.getTbSupplies().remove(this);
        return this;
    }

    public void setTbGuidelines(Set<TBGuideline> tBGuidelines) {
        this.tbGuidelines = tBGuidelines;
    }
    // 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;
        }
        TBSupplies tBSupplies = (TBSupplies) o;
        if (tBSupplies.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), tBSupplies.getId());
    }

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

    @Override
    public String toString() {
        return "TBSupplies{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", ingredient='" + getIngredient() + "'" +
            ", use='" + getUse() + "'" +
            ", sku='" + getSku() + "'" +
            ", description='" + getDescription() + "'" +
            ", manufacturer='" + getManufacturer() + "'" +
            ", quarantinePeriod=" + getQuarantinePeriod() +
            ", dosage='" + getDosage() + "'" +
            ", packaging='" + getPackaging() + "'" +
            ", jhiSize=" + getJhiSize() +
            ", unit='" + getUnit() + "'" +
            ", createdDate='" + getCreatedDate() + "'" +
            ", modifiedDate='" + getModifiedDate() + "'" +
            ", deletedDate='" + getDeletedDate() + "'" +
            "}";
    }
}
