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.util.Objects;

/**
 * A TBAddress.
 */
@Entity
@Table(name = "tb_address")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_tbaddress")
public class TBAddress implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

    @ManyToOne
    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    private TBCountry tbCountry;

    @ManyToOne
    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    private TBCity tbCity;

    @ManyToOne
    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    private TBDistrict tbDistrict;

    @ManyToOne
    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    private TBWard tbWard;

    // 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 getAddress() {
        return address;
    }

    public TBAddress address(String address) {
        this.address = address;
        return this;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public TBCountry getTbCountry() {
        return tbCountry;
    }

    public TBAddress tbCountry(TBCountry tBCountry) {
        this.tbCountry = tBCountry;
        return this;
    }

    public void setTbCountry(TBCountry tBCountry) {
        this.tbCountry = tBCountry;
    }

    public TBCity getTbCity() {
        return tbCity;
    }

    public TBAddress tbCity(TBCity tBCity) {
        this.tbCity = tBCity;
        return this;
    }

    public void setTbCity(TBCity tBCity) {
        this.tbCity = tBCity;
    }

    public TBDistrict getTbDistrict() {
        return tbDistrict;
    }

    public TBAddress tbDistrict(TBDistrict tBDistrict) {
        this.tbDistrict = tBDistrict;
        return this;
    }

    public void setTbDistrict(TBDistrict tBDistrict) {
        this.tbDistrict = tBDistrict;
    }

    public TBWard getTbWard() {
        return tbWard;
    }

    public TBAddress tbWard(TBWard tBWard) {
        this.tbWard = tBWard;
        return this;
    }

    public void setTbWard(TBWard tBWard) {
        this.tbWard = tBWard;
    }
    // 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;
        }
        TBAddress tBAddress = (TBAddress) o;
        if (tBAddress.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), tBAddress.getId());
    }

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

    @Override
    public String toString() {
        return "TBAddress{" +
            "id=" + getId() +
            ", address='" + getAddress() + "'" +
            "}";
    }
}
