@Test public void testIntersect() { final Interval<Integer> interval1 = new Interval<Integer>(3, 4); final Interval<Integer> interval2 = new Interval<Integer>(4, 6); Assert.assertEquals(new Interval<Integer>(4, 4), interval1.intersect(interval2)); }
public Interval<NUMBER_TYPE> intersect(final Interval<NUMBER_TYPE> interval) { Assert.paramNotNull(interval, "interval"); final NUMBER_TYPE min = NumberUtils.max(leftBoundary, interval.getLeftBoundary()); final NUMBER_TYPE max = NumberUtils.min(rightBoundary, interval.getRightBoundary()); if (min != null && max != null && NumberUtils.compareTo(min, max) <= 0) { return new Interval<NUMBER_TYPE>(min, max); } else { return null; } }
Interval { public Interval<NUMBER_TYPE> intersect(final Interval<NUMBER_TYPE> interval) { Assert.paramNotNull(interval, "interval"); final NUMBER_TYPE min = NumberUtils.max(leftBoundary, interval.getLeftBoundary()); final NUMBER_TYPE max = NumberUtils.min(rightBoundary, interval.getRightBoundary()); if (min != null && max != null && NumberUtils.compareTo(min, max) <= 0) { return new Interval<NUMBER_TYPE>(min, max); } else { return null; } } }
Interval { public Interval<NUMBER_TYPE> intersect(final Interval<NUMBER_TYPE> interval) { Assert.paramNotNull(interval, "interval"); final NUMBER_TYPE min = NumberUtils.max(leftBoundary, interval.getLeftBoundary()); final NUMBER_TYPE max = NumberUtils.min(rightBoundary, interval.getRightBoundary()); if (min != null && max != null && NumberUtils.compareTo(min, max) <= 0) { return new Interval<NUMBER_TYPE>(min, max); } else { return null; } } Interval(final Interval<NUMBER_TYPE> original);  Interval(final NUMBER_TYPE leftBoundary, final NUMBER_TYPE rightBoundary);  Interval(
        final NUMBER_TYPE leftBoundary,
        final boolean leftOpen,
        final NUMBER_TYPE rightBoundary,
        final boolean rightOpen); }
Interval { public Interval<NUMBER_TYPE> intersect(final Interval<NUMBER_TYPE> interval) { Assert.paramNotNull(interval, "interval"); final NUMBER_TYPE min = NumberUtils.max(leftBoundary, interval.getLeftBoundary()); final NUMBER_TYPE max = NumberUtils.min(rightBoundary, interval.getRightBoundary()); if (min != null && max != null && NumberUtils.compareTo(min, max) <= 0) { return new Interval<NUMBER_TYPE>(min, max); } else { return null; } } Interval(final Interval<NUMBER_TYPE> original);  Interval(final NUMBER_TYPE leftBoundary, final NUMBER_TYPE rightBoundary);  Interval(
        final NUMBER_TYPE leftBoundary,
        final boolean leftOpen,
        final NUMBER_TYPE rightBoundary,
        final boolean rightOpen); Interval<NUMBER_TYPE> createCopy(); NUMBER_TYPE getLeftBoundary(); boolean isLeftOpen(); NUMBER_TYPE getRightBoundary(); boolean isRightOpen(); Interval<NUMBER_TYPE> intersect(final Interval<NUMBER_TYPE> interval); Interval<NUMBER_TYPE> intersect(final Iterable<Interval<NUMBER_TYPE>> intervals); Interval<NUMBER_TYPE> closure(final Interval<NUMBER_TYPE> interval); Interval<NUMBER_TYPE> closure(final Iterable<Interval<NUMBER_TYPE>> intervals); static Interval<T> closureOf(final Interval<T> interval1, final Interval<T> interval2); static Interval<T> closureOf(final Iterable<Interval<T>> intervals); Interval<NUMBER_TYPE> union(final Interval<NUMBER_TYPE> interval); boolean contains(final NUMBER_TYPE number); boolean contains(final Interval<NUMBER_TYPE> other); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); }
Interval { public Interval<NUMBER_TYPE> intersect(final Interval<NUMBER_TYPE> interval) { Assert.paramNotNull(interval, "interval"); final NUMBER_TYPE min = NumberUtils.max(leftBoundary, interval.getLeftBoundary()); final NUMBER_TYPE max = NumberUtils.min(rightBoundary, interval.getRightBoundary()); if (min != null && max != null && NumberUtils.compareTo(min, max) <= 0) { return new Interval<NUMBER_TYPE>(min, max); } else { return null; } } Interval(final Interval<NUMBER_TYPE> original);  Interval(final NUMBER_TYPE leftBoundary, final NUMBER_TYPE rightBoundary);  Interval(
        final NUMBER_TYPE leftBoundary,
        final boolean leftOpen,
        final NUMBER_TYPE rightBoundary,
        final boolean rightOpen); Interval<NUMBER_TYPE> createCopy(); NUMBER_TYPE getLeftBoundary(); boolean isLeftOpen(); NUMBER_TYPE getRightBoundary(); boolean isRightOpen(); Interval<NUMBER_TYPE> intersect(final Interval<NUMBER_TYPE> interval); Interval<NUMBER_TYPE> intersect(final Iterable<Interval<NUMBER_TYPE>> intervals); Interval<NUMBER_TYPE> closure(final Interval<NUMBER_TYPE> interval); Interval<NUMBER_TYPE> closure(final Iterable<Interval<NUMBER_TYPE>> intervals); static Interval<T> closureOf(final Interval<T> interval1, final Interval<T> interval2); static Interval<T> closureOf(final Iterable<Interval<T>> intervals); Interval<NUMBER_TYPE> union(final Interval<NUMBER_TYPE> interval); boolean contains(final NUMBER_TYPE number); boolean contains(final Interval<NUMBER_TYPE> other); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }