Interval extends PartiallyOrdered<Interval<C>> implements Comparable<Interval<C>> { @Override public boolean equals(final Object that) { if (!(that instanceof Interval)) { return false; } if (that == this) { return true; } Interval interval = (Interval) that; if(interval.dimension == this.dimension) { if(this.hasNone()) { if(interval.hasNone()) { return true; } return false; } if(interval.hasNone()) { if(this.hasNone()) { return true; } return false; } return interval.range.equals(this.range); } return false; } private  Interval(); private  Interval(int dimension); private  Interval(final Range<C> range);  Interval(int dimension, final Range<C> range); @Override Interval<C> intersect(final Interval<C> that); @Override Interval<C> union(final Interval<C> that); Interval<C> coalesce(final Interval<C> that); @Override double measure(); boolean isConnected(final Interval<C> that); boolean hasAll(); boolean hasNone(); boolean isDimensionless(); int getDimension(); @Beta Difference<C> minus(final Interval<C> that); @Beta Difference<C> complement(); Interval<C> ahead(); Interval<C> behind(); Interval<C> gap(final Interval<C> that); boolean before(final Interval<C> that); boolean after(final Interval<C> that); boolean between(final Interval<C> that, final Interval<C> other); boolean overlaps(final Interval<C> that); boolean then(final Interval<C> that); boolean starts(final Interval<C> that); boolean ends(final Interval<C> that); @Override boolean equals(final Object that); @Override String toString(); @Override int hashCode(); Range<C> toRange(); @Override int compareTo(Interval<C> that); final static Interval NULL; final static Interval MAGIC; }
@Test public void testEquals() { assertTrue(a.equals(a)); assertTrue(a.equals(new Interval<>(1, Range.closed(2, 4)))); assertFalse(a.equals(b)); assertFalse(a.equals(Interval.NULL)); assertFalse(a.equals(Interval.MAGIC)); }