DiscreteInterval { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (max ^ (max >>> 32)); result = prime * result + (int) (min ^ (min >>> 32)); return result; } DiscreteInterval(long min, long max); long getMin(); long getMax(); long size(); DiscreteInterval plus(DiscreteInterval other); DiscreteInterval negate(); DiscreteInterval minus(DiscreteInterval other); boolean contains(DiscreteInterval other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void hashCodesOfEqualIntervalsAreEqual() { DiscreteInterval i1 = new DiscreteInterval(1,6); DiscreteInterval i2 = new DiscreteInterval(1,6); assertEquals(i1.hashCode(), i2.hashCode()); }
@Test public void hashCodesOfUnequalIntervalsAreEqual() { DiscreteInterval i1 = new DiscreteInterval(1,6); DiscreteInterval i2 = new DiscreteInterval(2,3); assertFalse(i1.hashCode() == i2.hashCode()); }