IntervalSet implements TimeSet<Interval> { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final IntervalSet other = (IntervalSet) obj; if (this.size != other.size) { return false; } int realSize = size * 2; for (int i = 0; i < realSize; i++) { double i1 = this.array[i]; double i2 = other.array[i]; if (i1 != i2) { return false; } } return true; } IntervalSet();  IntervalSet(int capacity);  IntervalSet(double[] arr); @Override boolean add(Interval interval); @Override boolean remove(Interval interval); @Override int size(); @Override boolean isEmpty(); boolean contains(double timestamp); @Override boolean contains(Interval interval); double[] getIntervals(); @Override Interval[] toArray(); @Override Object toPrimitiveArray(); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(TimeFormat timeFormat, DateTimeZone timeZone); @Override String toString(TimeFormat timeFormat); @Override String toString();  }
@Test public void testEquals() { IntervalSet set1 = new IntervalSet(); set1.add(new Interval(6.0, 7.0)); set1.add(new Interval(1.0, 2.0)); IntervalSet set2 = new IntervalSet(); set2.add(new Interval(6.0, 7.0)); set2.add(new Interval(1.0, 2.0)); IntervalSet set3 = new IntervalSet(); set3.add(new Interval(6.0, 7.0)); set3.add(new Interval(2.0, 3.0)); Assert.assertTrue(set1.equals(set2)); Assert.assertTrue(set2.equals(set1)); Assert.assertFalse(set1.equals(set3)); Assert.assertFalse(set3.equals(set1)); Assert.assertTrue(set1.hashCode() == set2.hashCode()); Assert.assertFalse(set1.hashCode() == set3.hashCode()); }