IntegerValue implements Value<Integer> { @Override public int compareTo(Value<Integer> arg) { if (arg == null) { return -1; } Double other = arg.getDouble(); if (value == null) { if (other == null) { return 0; } return 1; } else if (other == null) { return -1; } return getDouble().compareTo(other); } IntegerValue(Integer value); @Override Double getDouble(); @Override Integer getValue(); @Override void setValue(Integer value); @Override int compareTo(Value<Integer> arg); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void compareToTest() { IntegerValue dnull = new IntegerValue(null); IntegerValue dnull1 = new IntegerValue(null); IntegerValue d1 = new IntegerValue(1); IntegerValue d11 = new IntegerValue(1); IntegerValue d2 = new IntegerValue(2); Assert.assertEquals(0, dnull.compareTo(dnull1)); Assert.assertEquals(0, d1.compareTo(d11)); Assert.assertEquals(dnull, dnull1); Assert.assertEquals(d1, d11); Assert.assertTrue(dnull.compareTo(d1) > 0); Assert.assertTrue(d1.compareTo(dnull) < 0); Assert.assertTrue(d1.compareTo(d2) < 0); Assert.assertTrue(d2.compareTo(d1) > 0); }