package vn.azteam.tpf.domain;

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 TBEntity.
 */
@Entity
@Table(name = "tb_entity")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_tbentity")
public class TBEntity implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

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

    @Column(name = "area_m_2")
    private Double areaM2;

    @Column(name = "jhi_level")
    private Integer level;

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

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

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

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

    @ManyToOne
    @JsonIgnoreProperties("")
    @JoinColumn(name = "parent_id")
    private TBEntity tbEntity;

    @ManyToOne
    @JoinColumn(name = "tb_entity_type_id")
    private TBEntityType tbEntityType;

    @ManyToOne
    @JsonIgnoreProperties("")
    private TBAddress tbAddress;

    @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;

    // 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 getQrCode() {
        return qrCode;
    }

    public TBEntity qrCode(String qrCode) {
        this.qrCode = qrCode;
        return this;
    }

    public void setQrCode(String qrCode) {
        this.qrCode = qrCode;
    }

    public String getName() {
        return name;
    }

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

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

    public Double getAreaM2() {
        return areaM2;
    }

    public TBEntity areaM2(Double areaM2) {
        this.areaM2 = areaM2;
        return this;
    }

    public void setAreaM2(Double areaM2) {
        this.areaM2 = areaM2;
    }

    public Integer getLevel() {
        return level;
    }

    public TBEntity level(Integer level) {
        this.level = level;
        return this;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getStatus() {
        return status;
    }

    public TBEntity status(String status) {
        this.status = status;
        return this;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Instant getCreatedDate() {
        return createdDate;
    }

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

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

    public Instant getModifiedDate() {
        return modifiedDate;
    }

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

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

    public Instant getDeletedDate() {
        return deletedDate;
    }

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

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

    public TBEntity getTbEntity() {
        return tbEntity;
    }

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

    public void setTbEntity(TBEntity tBEntity) {
        this.tbEntity = tBEntity;
    }

    public TBAddress getTbAddress() {
        return tbAddress;
    }

    public TBEntity tbAddress(TBAddress tBAddress) {
        this.tbAddress = tBAddress;
        return this;
    }

    public void setTbAddress(TBAddress tBAddress) {
        this.tbAddress = tBAddress;
    }

    public TBDetailUser getCreatedBy() {
        return createdBy;
    }

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

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

    public TBDetailUser getModifiedBy() {
        return modifiedBy;
    }

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

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

    public TBDetailUser getDeletedBy() {
        return deletedBy;
    }

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

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

    public TBCustomer getTbCustomer() {
        return tbCustomer;
    }

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

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

    public TBEntityType getTbEntityType() {
        return tbEntityType;
    }

    public TBEntity tbEntityType(TBEntityType tbEntityType) {
        this.tbEntityType = tbEntityType;
        return this;
    }

    public void setTbEntityType(TBEntityType tbEntityType) {
        this.tbEntityType = tbEntityType;
    }
    // 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;
        }
        TBEntity tBEntity = (TBEntity) o;
        if (tBEntity.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), tBEntity.getId());
    }

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

    @Override
    public String toString() {
        return "TBEntity{" +
            "id=" + getId() +
            ", qrCode='" + getQrCode() + "'" +
            ", name='" + getName() + "'" +
            ", areaM2=" + getAreaM2() +
            ", level=" + getLevel() +
            ", status='" + getStatus() + "'" +
            ", createdDate='" + getCreatedDate() + "'" +
            ", modifiedDate='" + getModifiedDate() + "'" +
            ", deletedDate='" + getDeletedDate() + "'" +
            "}";
    }
}
