package it.sw.pa.comune.artegna.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import java.io.Serial;
import java.io.Serializable;
import java.time.Instant;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * A Messaggio.
 */
@Entity
@Table(name = "messaggio")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SuppressWarnings("common-java:DuplicatedBlocks")
public class Messaggio implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
    @SequenceGenerator(name = "sequenceGenerator")
    @Column(name = "id")
    private Long id;

    @Column(name = "spedito")
    private Instant spedito;

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

    @Column(name = "letto")
    private Instant letto;

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = { "internalUser", "liberatories" }, allowSetters = true)
    private UtenteApp utente;

    // jhipster-needle-entity-add-field - JHipster will add fields here

    public Long getId() {
        return this.id;
    }

    public Messaggio id(Long id) {
        this.setId(id);
        return this;
    }

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

    public Instant getSpedito() {
        return this.spedito;
    }

    public Messaggio spedito(Instant spedito) {
        this.setSpedito(spedito);
        return this;
    }

    public void setSpedito(Instant spedito) {
        this.spedito = spedito;
    }

    public String getTesto() {
        return this.testo;
    }

    public Messaggio testo(String testo) {
        this.setTesto(testo);
        return this;
    }

    public void setTesto(String testo) {
        this.testo = testo;
    }

    public Instant getLetto() {
        return this.letto;
    }

    public Messaggio letto(Instant letto) {
        this.setLetto(letto);
        return this;
    }

    public void setLetto(Instant letto) {
        this.letto = letto;
    }

    public UtenteApp getUtente() {
        return this.utente;
    }

    public void setUtente(UtenteApp utenteApp) {
        this.utente = utenteApp;
    }

    public Messaggio utente(UtenteApp utenteApp) {
        this.setUtente(utenteApp);
        return this;
    }

    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Messaggio)) {
            return false;
        }
        return getId() != null && getId().equals(((Messaggio) o).getId());
    }

    @Override
    public int hashCode() {
        // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
        return getClass().hashCode();
    }

    // prettier-ignore
    @Override
    public String toString() {
        return "Messaggio{" +
            "id=" + getId() +
            ", spedito='" + getSpedito() + "'" +
            ", testo='" + getTesto() + "'" +
            ", letto='" + getLetto() + "'" +
            "}";
    }
}
