Interval extends Pair<T, T> { public Interval(T start, T end) { this(true, start, end, true); } Interval(T start, T end);  Interval(boolean includeFirst, T start, T end, boolean includeLast); boolean contains(T value); boolean precedes(T value); boolean after(T value); @Override String toString();  }
@Test public void testInterval() { Interval<Integer> i = new Interval<Integer>(true, 5, 20, true); assertEquals(i.toString(), "[5,20]"); assertFalse(i.contains(-10)); assertTrue(i.contains(5)); assertTrue(i.contains(7)); assertTrue(i.contains(20)); assertFalse(i.contains(21)); i = new Interval<Integer>(false, 5, 20, true); assertEquals(i.toString(), "]5,20]"); assertFalse(i.contains(-10)); assertFalse(i.contains(5)); assertTrue(i.contains(7)); assertTrue(i.contains(20)); assertFalse(i.contains(21)); i = new Interval<Integer>(false, 5, 20, false); assertEquals(i.toString(), "]5,20["); assertFalse(i.contains(-10)); assertFalse(i.contains(5)); assertTrue(i.contains(7)); assertFalse(i.contains(20)); assertFalse(i.contains(21)); i = new Interval<Integer>(true, 5, 20, false); assertEquals(i.toString(), "[5,20["); assertFalse(i.contains(-10)); assertTrue(i.contains(5)); assertTrue(i.contains(7)); assertFalse(i.contains(20)); assertFalse(i.contains(21)); }