DistancePoint implements Comparable<DistancePoint> { @Override public int compareTo(final DistancePoint o) { return distance.compareTo(o.distance); } DistancePoint(final Double distance, final Position point);  DistancePoint(final Position point, final Double distance); @Override int compareTo(final DistancePoint o);  }
@Test public void testCompareTo() { boolean expected; int actual; Position point; Double distance; point = Point.builder().longitude(0.1d).latitude(20.0d).build(); distance = 1000.0d; final DistancePoint distancePoint = DistancePoint.builder().distance(distance).point(point) .build(); point = Point.builder().longitude(0.2d).latitude(3.5d).build(); distance = 20.0d; DistancePoint anotherPoint = DistancePoint.builder().distance(distance).point(point) .build(); actual = distancePoint.compareTo(anotherPoint); expected = 0 < actual; assertTrue(expected); }