RangeImpl implements Range { @Override public int hashCode() { int result = lowBoundary != null ? lowBoundary.hashCode() : 0; result = 31 * result + (highBoundary != null ? highBoundary.hashCode() : 0); result = 31 * result + (lowEndPoint != null ? lowEndPoint.hashCode() : 0); result = 31 * result + (highEndPoint != null ? highEndPoint.hashCode() : 0); return result; } RangeImpl();  RangeImpl(RangeBoundary lowBoundary, Comparable lowEndPoint, Comparable highEndPoint, RangeBoundary highBoundary); @Override RangeBoundary getLowBoundary(); @Override Comparable getLowEndPoint(); @Override Comparable getHighEndPoint(); @Override RangeBoundary getHighBoundary(); @Override Boolean includes(Object param); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void hashCodeTest() { final RangeImpl rangeImpl = new RangeImpl(Range.RangeBoundary.OPEN, 10, 15, Range.RangeBoundary.OPEN); Assert.assertEquals(rangeImpl.hashCode(), rangeImpl.hashCode()); RangeImpl rangeImpl2 = new RangeImpl(Range.RangeBoundary.OPEN, 10, 15, Range.RangeBoundary.OPEN); Assert.assertEquals(rangeImpl.hashCode(), rangeImpl2.hashCode()); rangeImpl2 = new RangeImpl(Range.RangeBoundary.OPEN, 10, 15, Range.RangeBoundary.CLOSED); Assert.assertNotEquals(rangeImpl.hashCode(), rangeImpl2.hashCode()); rangeImpl2 = new RangeImpl(Range.RangeBoundary.CLOSED, 10, 15, Range.RangeBoundary.OPEN); Assert.assertNotEquals(rangeImpl.hashCode(), rangeImpl2.hashCode()); rangeImpl2 = new RangeImpl(Range.RangeBoundary.CLOSED, 10, 15, Range.RangeBoundary.CLOSED); Assert.assertNotEquals(rangeImpl.hashCode(), rangeImpl2.hashCode()); rangeImpl2 = new RangeImpl(Range.RangeBoundary.CLOSED, 12, 15, Range.RangeBoundary.CLOSED); Assert.assertNotEquals(rangeImpl.hashCode(), rangeImpl2.hashCode()); rangeImpl2 = new RangeImpl(Range.RangeBoundary.CLOSED, 12, 17, Range.RangeBoundary.CLOSED); Assert.assertNotEquals(rangeImpl.hashCode(), rangeImpl2.hashCode()); }