package com.oguerreiro.resilient.service.criteria;

import java.util.Objects;
import java.util.Optional;

import org.springdoc.core.annotations.ParameterObject;

import tech.jhipster.service.filter.Filter;
import tech.jhipster.service.filter.LongFilter;
import tech.jhipster.service.filter.StringFilter;

/**
 * Criteria class for the {@link com.oguerreiro.resilient.domain.OutputData}
 * entity. This class is used in
 * {@link com.oguerreiro.resilient.web.rest.OutputDataResource} to receive all
 * the possible filtering options from the Http GET request parameters. For
 * example the following could be a valid request:
 * {@code /input-data?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
public class OutputDataCriteria extends AbstractCriteria {
  private static final long serialVersionUID = 1L;

  private LongFilter id;

  private LongFilter variableId;

  private StringFilter variableNameOrCode;

  private LongFilter periodId;

  private LongFilter periodVersionId;

  private LongFilter ownerId;

  private LongFilter variableScopeId;
  private LongFilter variableCategoryId;

  public OutputDataCriteria() {
  }

  public OutputDataCriteria(OutputDataCriteria other) {
    super(other);

    this.id = other.optionalId().map(LongFilter::copy).orElse(null);
    this.variableId = other.optionalVariableId().map(LongFilter::copy).orElse(null);
    this.variableNameOrCode = other.optionalVariableNameOrCode().map(StringFilter::copy).orElse(null);
    this.periodId = other.optionalPeriodId().map(LongFilter::copy).orElse(null);
    this.periodVersionId = other.optionalPeriodVersionId().map(LongFilter::copy).orElse(null);
    this.ownerId = other.optionalOwnerId().map(LongFilter::copy).orElse(null);
    this.variableScopeId = other.optionalVariableScopeId().map(LongFilter::copy).orElse(null);
    this.variableCategoryId = other.optionalVariableCategoryId().map(LongFilter::copy).orElse(null);
  }

  @Override
  public OutputDataCriteria copy() {
    return new OutputDataCriteria(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 LongFilter getVariableId() {
    return variableId;
  }

  public Optional<LongFilter> optionalVariableId() {
    return Optional.ofNullable(variableId);
  }

  public LongFilter variableId() {
    if (variableId == null) {
      setVariableId(new LongFilter());
    }
    return variableId;
  }

  public void setVariableId(LongFilter variableId) {
    this.variableId = variableId;
  }

  public StringFilter getVariableNameOrCode() {
    return variableNameOrCode;
  }

  public Optional<StringFilter> optionalVariableNameOrCode() {
    return Optional.ofNullable(variableNameOrCode);
  }

  public StringFilter variableNameOrCode() {
    if (variableNameOrCode == null) {
      setVariableNameOrCode(new StringFilter());
    }
    return variableNameOrCode;
  }

  public void setVariableNameOrCode(StringFilter variableNameOrCode) {
    this.variableNameOrCode = variableNameOrCode;
  }

  public LongFilter getPeriodId() {
    return periodId;
  }

  public Optional<LongFilter> optionalPeriodId() {
    return Optional.ofNullable(periodId);
  }

  public LongFilter periodId() {
    if (periodId == null) {
      setPeriodId(new LongFilter());
    }
    return periodId;
  }

  public void setPeriodId(LongFilter periodId) {
    this.periodId = periodId;
  }

  public LongFilter getPeriodVersionId() {
    return periodVersionId;
  }

  public Optional<LongFilter> optionalPeriodVersionId() {
    return Optional.ofNullable(periodVersionId);
  }

  public LongFilter periodVersionId() {
    if (periodVersionId == null) {
      setPeriodVersionId(new LongFilter());
    }
    return periodVersionId;
  }

  public void setPeriodVersionId(LongFilter periodVersionId) {
    this.periodVersionId = periodVersionId;
  }

  public LongFilter getOwnerId() {
    return ownerId;
  }

  public Optional<LongFilter> optionalOwnerId() {
    return Optional.ofNullable(ownerId);
  }

  public LongFilter ownerId() {
    if (ownerId == null) {
      setOwnerId(new LongFilter());
    }
    return ownerId;
  }

  public void setOwnerId(LongFilter ownerId) {
    this.ownerId = ownerId;
  }

  public LongFilter getVariableScopeId() {
    return variableScopeId;
  }

  public Optional<LongFilter> optionalVariableScopeId() {
    return Optional.ofNullable(variableScopeId);
  }

  public LongFilter variableScopeId() {
    if (variableScopeId == null) {
      setVariableScopeId(new LongFilter());
    }
    return variableScopeId;
  }

  public void setVariableScopeId(LongFilter variableScopeId) {
    this.variableScopeId = variableScopeId;
  }

  public LongFilter getVariableCategoryId() {
    return variableCategoryId;
  }

  public Optional<LongFilter> optionalVariableCategoryId() {
    return Optional.ofNullable(variableCategoryId);
  }

  public LongFilter variableCategoryId() {
    if (variableCategoryId == null) {
      setVariableCategoryId(new LongFilter());
    }
    return variableCategoryId;
  }

  public void setVariableCategoryId(LongFilter variableCategoryId) {
    this.variableCategoryId = variableCategoryId;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    final OutputDataCriteria that = (OutputDataCriteria) o;

    // @formatter:off
    return (Objects.equals(id, that.id) 
        && Objects.equals(variableId, that.variableId)
        && Objects.equals(variableScopeId, that.variableScopeId)
        && Objects.equals(variableCategoryId, that.variableCategoryId)
        && Objects.equals(variableNameOrCode, that.variableNameOrCode) 
        && Objects.equals(periodId, that.periodId)
        && Objects.equals(periodVersionId, that.periodVersionId) 
        && Objects.equals(ownerId, that.ownerId)
        && super.equals(o));
    // @formatter:on
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, variableId, variableScopeId, variableCategoryId, variableNameOrCode, periodId,
        periodVersionId, ownerId, super.hashCode());
  }

  // prettier-ignore
  @Override
  public String toString() {
    return "InputDataCriteria{" + optionalId().map(f -> "id=" + f + ", ").orElse("")
        + optionalVariableId().map(f -> "variableId=" + f + ", ").orElse("")
        + optionalVariableScopeId().map(f -> "variableScopeId=" + f + ", ").orElse("")
        + optionalVariableCategoryId().map(f -> "variableCategoryId=" + f + ", ").orElse("")
        + optionalVariableNameOrCode().map(f -> "variableNameOrCode=" + f + ", ").orElse("")
        + optionalPeriodId().map(f -> "periodId=" + f + ", ").orElse("")
        + optionalPeriodVersionId().map(f -> "periodVersionId=" + f + ", ").orElse("")
        + optionalOwnerId().map(f -> "ownerId=" + f + ", ").orElse("") + super.toString() + "}";
  }
}
