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.BigDecimalFilter;
import tech.jhipster.service.filter.Filter;
import tech.jhipster.service.filter.IntegerFilter;
import tech.jhipster.service.filter.LongFilter;
import tech.jhipster.service.filter.StringFilter;

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

  private LongFilter id;

  private IntegerFilter year;

  private StringFilter emissionFactorNameOrCode;

  private StringFilter code;

  private StringFilter name;

  private StringFilter unit;

  private StringFilter source;

  private StringFilter comments;

  private LongFilter variableScopeId;

  private LongFilter variableCategoryId;

  private BigDecimalFilter value;

  public EmissionFactorCriteria() {
  }

  public EmissionFactorCriteria(EmissionFactorCriteria other) {
    super(other);

    this.id = other.optionalId().map(LongFilter::copy).orElse(null);
    this.year = other.optionalYear().map(IntegerFilter::copy).orElse(null);
    this.emissionFactorNameOrCode = other.optionalEmissionFactorNameOrCode().map(StringFilter::copy).orElse(null);
    this.code = other.optionalCode().map(StringFilter::copy).orElse(null);
    this.name = other.optionalName().map(StringFilter::copy).orElse(null);
    this.unit = other.optionalUnit().map(StringFilter::copy).orElse(null);
    this.source = other.optionalSource().map(StringFilter::copy).orElse(null);
    this.comments = other.optionalComments().map(StringFilter::copy).orElse(null);
    this.variableScopeId = other.optionalVariableScopeId().map(LongFilter::copy).orElse(null);
    this.variableCategoryId = other.optionalVariableCategoryId().map(LongFilter::copy).orElse(null);
    this.value = other.optionalValue().map(BigDecimalFilter::copy).orElse(null);
  }

  @Override
  public EmissionFactorCriteria copy() {
    return new EmissionFactorCriteria(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 IntegerFilter getYear() {
    return year;
  }

  public Optional<IntegerFilter> optionalYear() {
    return Optional.ofNullable(year);
  }

  public IntegerFilter year() {
    if (year == null) {
      setYear(new IntegerFilter());
    }
    return year;
  }

  public void setYear(IntegerFilter year) {
    this.year = year;
  }

  public StringFilter getEmissionFactorNameOrCode() {
    return emissionFactorNameOrCode;
  }

  public Optional<StringFilter> optionalEmissionFactorNameOrCode() {
    return Optional.ofNullable(emissionFactorNameOrCode);
  }

  public StringFilter emissionFactorNameOrCode() {
    if (emissionFactorNameOrCode == null) {
      setEmissionFactorNameOrCode(new StringFilter());
    }
    return emissionFactorNameOrCode;
  }

  public void setEmissionFactorNameOrCode(StringFilter emissionFactorNameOrCode) {
    this.emissionFactorNameOrCode = emissionFactorNameOrCode;
  }

  public StringFilter getCode() {
    return code;
  }

  public Optional<StringFilter> optionalCode() {
    return Optional.ofNullable(code);
  }

  public StringFilter code() {
    if (code == null) {
      setCode(new StringFilter());
    }
    return code;
  }

  public void setCode(StringFilter code) {
    this.code = code;
  }

  public StringFilter getName() {
    return name;
  }

  public Optional<StringFilter> optionalName() {
    return Optional.ofNullable(name);
  }

  public StringFilter name() {
    if (name == null) {
      setName(new StringFilter());
    }
    return name;
  }

  public void setName(StringFilter name) {
    this.name = name;
  }

  public StringFilter getUnit() {
    return unit;
  }

  public Optional<StringFilter> optionalUnit() {
    return Optional.ofNullable(unit);
  }

  public StringFilter unit() {
    if (unit == null) {
      setUnit(new StringFilter());
    }
    return unit;
  }

  public void setUnit(StringFilter unit) {
    this.unit = unit;
  }

  public StringFilter getSource() {
    return source;
  }

  public Optional<StringFilter> optionalSource() {
    return Optional.ofNullable(source);
  }

  public StringFilter souce() {
    if (source == null) {
      setSource(new StringFilter());
    }
    return source;
  }

  public void setSource(StringFilter source) {
    this.source = source;
  }

  public StringFilter getComments() {
    return comments;
  }

  public Optional<StringFilter> optionalComments() {
    return Optional.ofNullable(comments);
  }

  public StringFilter comments() {
    if (comments == null) {
      setComments(new StringFilter());
    }
    return comments;
  }

  public void setComments(StringFilter comments) {
    this.comments = comments;
  }

  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;
  }

  public BigDecimalFilter getValue() {
    return value;
  }

  public Optional<BigDecimalFilter> optionalValue() {
    return Optional.ofNullable(value);
  }

  public BigDecimalFilter value() {
    if (value == null) {
      setValue(new BigDecimalFilter());
    }
    return value;
  }

  public void setValue(BigDecimalFilter value) {
    this.value = value;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    final EmissionFactorCriteria that = (EmissionFactorCriteria) o;
    return (Objects.equals(id, that.id) && Objects.equals(year, that.year)
        && Objects.equals(emissionFactorNameOrCode, that.emissionFactorNameOrCode) && Objects.equals(code, that.code)
        && Objects.equals(name, that.name) && Objects.equals(unit, that.unit) && Objects.equals(source, that.source)
        && Objects.equals(comments, that.comments) && Objects.equals(variableScopeId, that.variableScopeId)
        && Objects.equals(variableCategoryId, that.variableCategoryId) && Objects.equals(value, that.value)
        && super.equals(o));
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, year, emissionFactorNameOrCode, code, name, unit, source, comments, variableScopeId,
        variableCategoryId, value, super.hashCode());
  }

  // prettier-ignore
  @Override
  public String toString() {
    //@formatter:off
    return "InputDataCriteria{" + optionalId().map(f -> "id=" + f + ", ").orElse("")
        + optionalYear().map(f -> "year=" + f + ", ").orElse("")
        + optionalEmissionFactorNameOrCode().map(f -> "emissionFactorNameOrCode=" + f + ", ").orElse("")
        + optionalCode().map(f -> "code=" + f + ", ").orElse("")
        + optionalName().map(f -> "name=" + f + ", ").orElse("")
        + optionalUnit().map(f -> "unit=" + f + ", ").orElse("")
        + optionalSource().map(f -> "source=" + f + ", ").orElse("")
        + optionalComments().map(f -> "comments=" + f + ", ").orElse("")
        + optionalVariableScopeId().map(f -> "variableScopeId=" + f + ", ").orElse("")
        + optionalVariableCategoryId().map(f -> "variableCategoryId=" + f + ", ").orElse("") 
        + optionalValue().map(f -> "value=" + f + ", ").orElse("")
        + super.toString() + "}";
  //@formatter:on
  }
}
