SimpleLength implements Length { @Override public boolean equals(final Object o) { if (!(o instanceof SimpleLength)) { return false; } final SimpleLength other = (SimpleLength) o; if (this.unit == other.unit) { final double delta = this.value - other.value; return (delta >= 0.0) ? (delta < MAX_DELTA) : (delta > -MAX_DELTA); } else { return false; } } SimpleLength(final double value, final Unit unit); static SimpleLength mm(final double value); static SimpleLength cm(final double value); static SimpleLength in(final double value); static SimpleLength pt(final double value); static SimpleLength pc(final double value); static SimpleLength em(final double value); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Override String getValue(); @Override boolean isNotNull();  }
@Test public void testEquals() { final SimpleLength l1 = SimpleLength.pt(10); final SimpleLength l2 = SimpleLength.pt(10 - 0.0000000000000001); final SimpleLength l3 = SimpleLength.pt(10 - 0.003); Assert.assertEquals(l1, l2); Assert.assertEquals(l2, l1); Assert.assertNotEquals(l1, l3); Assert.assertNotEquals(l3, l1); }