package it.sw.pa.comune.artegna.service.criteria;

import it.sw.pa.comune.artegna.domain.enumeration.TipoConferma;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import java.util.Optional;
import org.springdoc.core.annotations.ParameterObject;
import tech.jhipster.service.Criteria;
import tech.jhipster.service.filter.*;

/**
 * Criteria class for the {@link it.sw.pa.comune.artegna.domain.Conferma} entity. This class is used
 * in {@link it.sw.pa.comune.artegna.web.rest.ConfermaResource} to receive all the possible filtering options from
 * the Http GET request parameters.
 * For example the following could be a valid request:
 * {@code /confermas?id.greaterThan=5&attr1.contains=something&attr2.specified=false}
 * As Spring is unable to properly convert the types, unless specific {@link Filter} class are used, we need to use
 * fix type specific filters.
 */
@ParameterObject
@SuppressWarnings("common-java:DuplicatedBlocks")
public class ConfermaCriteria implements Serializable, Criteria {

    /**
     * Class for filtering TipoConferma
     */
    public static class TipoConfermaFilter extends Filter<TipoConferma> {

        public TipoConfermaFilter() {}

        public TipoConfermaFilter(TipoConfermaFilter filter) {
            super(filter);
        }

        @Override
        public TipoConfermaFilter copy() {
            return new TipoConfermaFilter(this);
        }
    }

    @Serial
    private static final long serialVersionUID = 1L;

    private LongFilter id;

    private StringFilter motivoConferma;

    private TipoConfermaFilter tipoConferma;

    private LongFilter confermataDaId;

    private LongFilter prenotazioneId;

    private Boolean distinct;

    public ConfermaCriteria() {}

    public ConfermaCriteria(ConfermaCriteria other) {
        this.id = other.optionalId().map(LongFilter::copy).orElse(null);
        this.motivoConferma = other.optionalMotivoConferma().map(StringFilter::copy).orElse(null);
        this.tipoConferma = other.optionalTipoConferma().map(TipoConfermaFilter::copy).orElse(null);
        this.confermataDaId = other.optionalConfermataDaId().map(LongFilter::copy).orElse(null);
        this.prenotazioneId = other.optionalPrenotazioneId().map(LongFilter::copy).orElse(null);
        this.distinct = other.distinct;
    }

    @Override
    public ConfermaCriteria copy() {
        return new ConfermaCriteria(this);
    }

    public LongFilter getId() {
        return id;
    }

    public Optional<LongFilter> optionalId() {
        return Optional.ofNullable(id);
    }

    public LongFilter id() {
        if (id == null) {
            setId(new LongFilter());
        }
        return id;
    }

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

    public StringFilter getMotivoConferma() {
        return motivoConferma;
    }

    public Optional<StringFilter> optionalMotivoConferma() {
        return Optional.ofNullable(motivoConferma);
    }

    public StringFilter motivoConferma() {
        if (motivoConferma == null) {
            setMotivoConferma(new StringFilter());
        }
        return motivoConferma;
    }

    public void setMotivoConferma(StringFilter motivoConferma) {
        this.motivoConferma = motivoConferma;
    }

    public TipoConfermaFilter getTipoConferma() {
        return tipoConferma;
    }

    public Optional<TipoConfermaFilter> optionalTipoConferma() {
        return Optional.ofNullable(tipoConferma);
    }

    public TipoConfermaFilter tipoConferma() {
        if (tipoConferma == null) {
            setTipoConferma(new TipoConfermaFilter());
        }
        return tipoConferma;
    }

    public void setTipoConferma(TipoConfermaFilter tipoConferma) {
        this.tipoConferma = tipoConferma;
    }

    public LongFilter getConfermataDaId() {
        return confermataDaId;
    }

    public Optional<LongFilter> optionalConfermataDaId() {
        return Optional.ofNullable(confermataDaId);
    }

    public LongFilter confermataDaId() {
        if (confermataDaId == null) {
            setConfermataDaId(new LongFilter());
        }
        return confermataDaId;
    }

    public void setConfermataDaId(LongFilter confermataDaId) {
        this.confermataDaId = confermataDaId;
    }

    public LongFilter getPrenotazioneId() {
        return prenotazioneId;
    }

    public Optional<LongFilter> optionalPrenotazioneId() {
        return Optional.ofNullable(prenotazioneId);
    }

    public LongFilter prenotazioneId() {
        if (prenotazioneId == null) {
            setPrenotazioneId(new LongFilter());
        }
        return prenotazioneId;
    }

    public void setPrenotazioneId(LongFilter prenotazioneId) {
        this.prenotazioneId = prenotazioneId;
    }

    public Boolean getDistinct() {
        return distinct;
    }

    public Optional<Boolean> optionalDistinct() {
        return Optional.ofNullable(distinct);
    }

    public Boolean distinct() {
        if (distinct == null) {
            setDistinct(true);
        }
        return distinct;
    }

    public void setDistinct(Boolean distinct) {
        this.distinct = distinct;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final ConfermaCriteria that = (ConfermaCriteria) o;
        return (
            Objects.equals(id, that.id) &&
            Objects.equals(motivoConferma, that.motivoConferma) &&
            Objects.equals(tipoConferma, that.tipoConferma) &&
            Objects.equals(confermataDaId, that.confermataDaId) &&
            Objects.equals(prenotazioneId, that.prenotazioneId) &&
            Objects.equals(distinct, that.distinct)
        );
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, motivoConferma, tipoConferma, confermataDaId, prenotazioneId, distinct);
    }

    // prettier-ignore
    @Override
    public String toString() {
        return "ConfermaCriteria{" +
            optionalId().map(f -> "id=" + f + ", ").orElse("") +
            optionalMotivoConferma().map(f -> "motivoConferma=" + f + ", ").orElse("") +
            optionalTipoConferma().map(f -> "tipoConferma=" + f + ", ").orElse("") +
            optionalConfermataDaId().map(f -> "confermataDaId=" + f + ", ").orElse("") +
            optionalPrenotazioneId().map(f -> "prenotazioneId=" + f + ", ").orElse("") +
            optionalDistinct().map(f -> "distinct=" + f + ", ").orElse("") +
        "}";
    }
}
