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 Liberatoria.
 */
@Entity
@Table(name = "liberatoria")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SuppressWarnings("common-java:DuplicatedBlocks")
public class Liberatoria 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 = "accettata")
    private Instant accettata;

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = { "struttura" }, allowSetters = true)
    private ModelloLiberatoria modelloLiberatoria;

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

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

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

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

    public Instant getAccettata() {
        return this.accettata;
    }

    public Liberatoria accettata(Instant accettata) {
        this.setAccettata(accettata);
        return this;
    }

    public void setAccettata(Instant accettata) {
        this.accettata = accettata;
    }

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

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

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

    public ModelloLiberatoria getModelloLiberatoria() {
        return this.modelloLiberatoria;
    }

    public void setModelloLiberatoria(ModelloLiberatoria modelloLiberatoria) {
        this.modelloLiberatoria = modelloLiberatoria;
    }

    public Liberatoria modelloLiberatoria(ModelloLiberatoria modelloLiberatoria) {
        this.setModelloLiberatoria(modelloLiberatoria);
        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 Liberatoria)) {
            return false;
        }
        return getId() != null && getId().equals(((Liberatoria) 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 "Liberatoria{" +
            "id=" + getId() +
            ", accettata='" + getAccettata() + "'" +
            "}";
    }
}
