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

import it.sw.pa.comune.artegna.domain.enumeration.AzioneAudit;
import it.sw.pa.comune.artegna.domain.enumeration.TipoEntita;
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.AuditLog} entity. This class is used
 * in {@link it.sw.pa.comune.artegna.web.rest.AuditLogResource} to receive all the possible filtering options from
 * the Http GET request parameters.
 * For example the following could be a valid request:
 * {@code /audit-logs?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 AuditLogCriteria implements Serializable, Criteria {

    /**
     * Class for filtering TipoEntita
     */
    public static class TipoEntitaFilter extends Filter<TipoEntita> {

        public TipoEntitaFilter() {}

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

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

    /**
     * Class for filtering AzioneAudit
     */
    public static class AzioneAuditFilter extends Filter<AzioneAudit> {

        public AzioneAuditFilter() {}

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

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

    @Serial
    private static final long serialVersionUID = 1L;

    private LongFilter id;

    private TipoEntitaFilter entitaTipo;

    private LongFilter entitaId;

    private AzioneAuditFilter azione;

    private StringFilter dettagli;

    private StringFilter ipAddress;

    private InstantFilter createdAt;

    private LongFilter utenteId;

    private Boolean distinct;

    public AuditLogCriteria() {}

    public AuditLogCriteria(AuditLogCriteria other) {
        this.id = other.optionalId().map(LongFilter::copy).orElse(null);
        this.entitaTipo = other.optionalEntitaTipo().map(TipoEntitaFilter::copy).orElse(null);
        this.entitaId = other.optionalEntitaId().map(LongFilter::copy).orElse(null);
        this.azione = other.optionalAzione().map(AzioneAuditFilter::copy).orElse(null);
        this.dettagli = other.optionalDettagli().map(StringFilter::copy).orElse(null);
        this.ipAddress = other.optionalIpAddress().map(StringFilter::copy).orElse(null);
        this.createdAt = other.optionalCreatedAt().map(InstantFilter::copy).orElse(null);
        this.utenteId = other.optionalUtenteId().map(LongFilter::copy).orElse(null);
        this.distinct = other.distinct;
    }

    @Override
    public AuditLogCriteria copy() {
        return new AuditLogCriteria(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 TipoEntitaFilter getEntitaTipo() {
        return entitaTipo;
    }

    public Optional<TipoEntitaFilter> optionalEntitaTipo() {
        return Optional.ofNullable(entitaTipo);
    }

    public TipoEntitaFilter entitaTipo() {
        if (entitaTipo == null) {
            setEntitaTipo(new TipoEntitaFilter());
        }
        return entitaTipo;
    }

    public void setEntitaTipo(TipoEntitaFilter entitaTipo) {
        this.entitaTipo = entitaTipo;
    }

    public LongFilter getEntitaId() {
        return entitaId;
    }

    public Optional<LongFilter> optionalEntitaId() {
        return Optional.ofNullable(entitaId);
    }

    public LongFilter entitaId() {
        if (entitaId == null) {
            setEntitaId(new LongFilter());
        }
        return entitaId;
    }

    public void setEntitaId(LongFilter entitaId) {
        this.entitaId = entitaId;
    }

    public AzioneAuditFilter getAzione() {
        return azione;
    }

    public Optional<AzioneAuditFilter> optionalAzione() {
        return Optional.ofNullable(azione);
    }

    public AzioneAuditFilter azione() {
        if (azione == null) {
            setAzione(new AzioneAuditFilter());
        }
        return azione;
    }

    public void setAzione(AzioneAuditFilter azione) {
        this.azione = azione;
    }

    public StringFilter getDettagli() {
        return dettagli;
    }

    public Optional<StringFilter> optionalDettagli() {
        return Optional.ofNullable(dettagli);
    }

    public StringFilter dettagli() {
        if (dettagli == null) {
            setDettagli(new StringFilter());
        }
        return dettagli;
    }

    public void setDettagli(StringFilter dettagli) {
        this.dettagli = dettagli;
    }

    public StringFilter getIpAddress() {
        return ipAddress;
    }

    public Optional<StringFilter> optionalIpAddress() {
        return Optional.ofNullable(ipAddress);
    }

    public StringFilter ipAddress() {
        if (ipAddress == null) {
            setIpAddress(new StringFilter());
        }
        return ipAddress;
    }

    public void setIpAddress(StringFilter ipAddress) {
        this.ipAddress = ipAddress;
    }

    public InstantFilter getCreatedAt() {
        return createdAt;
    }

    public Optional<InstantFilter> optionalCreatedAt() {
        return Optional.ofNullable(createdAt);
    }

    public InstantFilter createdAt() {
        if (createdAt == null) {
            setCreatedAt(new InstantFilter());
        }
        return createdAt;
    }

    public void setCreatedAt(InstantFilter createdAt) {
        this.createdAt = createdAt;
    }

    public LongFilter getUtenteId() {
        return utenteId;
    }

    public Optional<LongFilter> optionalUtenteId() {
        return Optional.ofNullable(utenteId);
    }

    public LongFilter utenteId() {
        if (utenteId == null) {
            setUtenteId(new LongFilter());
        }
        return utenteId;
    }

    public void setUtenteId(LongFilter utenteId) {
        this.utenteId = utenteId;
    }

    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 AuditLogCriteria that = (AuditLogCriteria) o;
        return (
            Objects.equals(id, that.id) &&
            Objects.equals(entitaTipo, that.entitaTipo) &&
            Objects.equals(entitaId, that.entitaId) &&
            Objects.equals(azione, that.azione) &&
            Objects.equals(dettagli, that.dettagli) &&
            Objects.equals(ipAddress, that.ipAddress) &&
            Objects.equals(createdAt, that.createdAt) &&
            Objects.equals(utenteId, that.utenteId) &&
            Objects.equals(distinct, that.distinct)
        );
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, entitaTipo, entitaId, azione, dettagli, ipAddress, createdAt, utenteId, distinct);
    }

    // prettier-ignore
    @Override
    public String toString() {
        return "AuditLogCriteria{" +
            optionalId().map(f -> "id=" + f + ", ").orElse("") +
            optionalEntitaTipo().map(f -> "entitaTipo=" + f + ", ").orElse("") +
            optionalEntitaId().map(f -> "entitaId=" + f + ", ").orElse("") +
            optionalAzione().map(f -> "azione=" + f + ", ").orElse("") +
            optionalDettagli().map(f -> "dettagli=" + f + ", ").orElse("") +
            optionalIpAddress().map(f -> "ipAddress=" + f + ", ").orElse("") +
            optionalCreatedAt().map(f -> "createdAt=" + f + ", ").orElse("") +
            optionalUtenteId().map(f -> "utenteId=" + f + ", ").orElse("") +
            optionalDistinct().map(f -> "distinct=" + f + ", ").orElse("") +
        "}";
    }
}
