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.UnitConverter}
 * entity. This class is used in
 * {@link com.oguerreiro.resilient.web.rest.UnitConverterResource} 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 UnitConverterCriteria extends AbstractCriteria {
  private static final long serialVersionUID = 1L;

  private LongFilter id;

  private StringFilter name;

  private StringFilter description;

  private LongFilter fromUnitId;

  private LongFilter toUnitId;

  public UnitConverterCriteria() {
    super();
  }

  public UnitConverterCriteria(UnitConverterCriteria other) {
    super(other);

    this.id = other.optionalId().map(LongFilter::copy).orElse(null);
    this.name = other.optionalName().map(StringFilter::copy).orElse(null);
    this.description = other.optionalDescription().map(StringFilter::copy).orElse(null);
    this.fromUnitId = other.optionalFromUnitId().map(LongFilter::copy).orElse(null);
    this.toUnitId = other.optionalToUnitId().map(LongFilter::copy).orElse(null);
  }

  @Override
  public UnitConverterCriteria copy() {
    return new UnitConverterCriteria(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 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 getDescription() {
    return description;
  }

  public Optional<StringFilter> optionalDescription() {
    return Optional.ofNullable(description);
  }

  public StringFilter description() {
    if (description == null) {
      setDescription(new StringFilter());
    }
    return description;
  }

  public void setDescription(StringFilter description) {
    this.description = description;
  }

  public LongFilter getFromUnitId() {
    return fromUnitId;
  }

  public Optional<LongFilter> optionalFromUnitId() {
    return Optional.ofNullable(fromUnitId);
  }

  public LongFilter fromUnitId() {
    if (fromUnitId == null) {
      setFromUnitId(new LongFilter());
    }
    return fromUnitId;
  }

  public void setFromUnitId(LongFilter fromUnitId) {
    this.fromUnitId = fromUnitId;
  }

  public LongFilter getToUnitId() {
    return toUnitId;
  }

  public Optional<LongFilter> optionalToUnitId() {
    return Optional.ofNullable(toUnitId);
  }

  public LongFilter toUnitId() {
    if (toUnitId == null) {
      setToUnitId(new LongFilter());
    }
    return toUnitId;
  }

  public void setToUnitId(LongFilter toUnitId) {
    this.toUnitId = toUnitId;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    final UnitConverterCriteria that = (UnitConverterCriteria) o;
    return (Objects.equals(id, that.id) && Objects.equals(name, that.name)
        && Objects.equals(description, that.description) && Objects.equals(fromUnitId, that.fromUnitId)
        && Objects.equals(toUnitId, that.toUnitId) && super.equals(o));
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, name, description, fromUnitId, toUnitId, super.hashCode());
  }

  // prettier-ignore
  @Override
  public String toString() {
    return "InputDataCriteria{" + optionalId().map(f -> "id=" + f + ", ").orElse("")
        + optionalName().map(f -> "name=" + f + ", ").orElse("")
        + optionalDescription().map(f -> "description=" + f + ", ").orElse("")
        + optionalFromUnitId().map(f -> "fromUnitId=" + f + ", ").orElse("")
        + optionalToUnitId().map(f -> "toUnitId=" + f + ", ").orElse("") + super.toString() + "}";
  }
}
