class DoubleComparator extends NullSafeComparator<Double> {

  private double precision;

  public DoubleComparator(double epsilon) {
    this.precision = epsilon;
  }

  @Override
  protected int compareNonNull(Double x, Double y) {
    if (closeEnough(x, y, precision)) return 0;
    return x < y ? -1 : 1;
  }

  public double getEpsilon() {
    return precision;
  }

  private static boolean closeEnough(Double x, Double y, double epsilon) {
    return x.doubleValue() == y.doubleValue() || Math.abs(x - y) <= epsilon;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    long temp = Double.doubleToLongBits(precision);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    return result;
  }

  @Override
  public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}

  @Override
  public String toString() {
    return format("DoubleComparator[precision=%s]", precision);
  }

}

    if (this == obj) return true;
    if (obj == null) return false;
    if (!(obj instanceof DoubleComparator)) return false;
    DoubleComparator other = (DoubleComparator) obj;
    return Double.doubleToLongBits(precision) == Double.doubleToLongBits(other.precision);
  
<methods>public int compare(java.lang.Double, java.lang.Double) <variables>