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

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

    @Lob
    @Column(name = "documento")
    private byte[] documento;

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

    @Column(name = "valido_dal")
    private Instant validoDal;

    @Column(name = "valido_al")
    private Instant validoAl;

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

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

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

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

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

    public String getNome() {
        return this.nome;
    }

    public ModelloLiberatoria nome(String nome) {
        this.setNome(nome);
        return this;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

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

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

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

    public byte[] getDocumento() {
        return this.documento;
    }

    public ModelloLiberatoria documento(byte[] documento) {
        this.setDocumento(documento);
        return this;
    }

    public void setDocumento(byte[] documento) {
        this.documento = documento;
    }

    public String getDocumentoContentType() {
        return this.documentoContentType;
    }

    public ModelloLiberatoria documentoContentType(String documentoContentType) {
        this.documentoContentType = documentoContentType;
        return this;
    }

    public void setDocumentoContentType(String documentoContentType) {
        this.documentoContentType = documentoContentType;
    }

    public Instant getValidoDal() {
        return this.validoDal;
    }

    public ModelloLiberatoria validoDal(Instant validoDal) {
        this.setValidoDal(validoDal);
        return this;
    }

    public void setValidoDal(Instant validoDal) {
        this.validoDal = validoDal;
    }

    public Instant getValidoAl() {
        return this.validoAl;
    }

    public ModelloLiberatoria validoAl(Instant validoAl) {
        this.setValidoAl(validoAl);
        return this;
    }

    public void setValidoAl(Instant validoAl) {
        this.validoAl = validoAl;
    }

    public Struttura getStruttura() {
        return this.struttura;
    }

    public void setStruttura(Struttura struttura) {
        this.struttura = struttura;
    }

    public ModelloLiberatoria struttura(Struttura struttura) {
        this.setStruttura(struttura);
        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 ModelloLiberatoria)) {
            return false;
        }
        return getId() != null && getId().equals(((ModelloLiberatoria) 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 "ModelloLiberatoria{" +
            "id=" + getId() +
            ", nome='" + getNome() + "'" +
            ", testo='" + getTesto() + "'" +
            ", documento='" + getDocumento() + "'" +
            ", documentoContentType='" + getDocumentoContentType() + "'" +
            ", validoDal='" + getValidoDal() + "'" +
            ", validoAl='" + getValidoAl() + "'" +
            "}";
    }
}
