Range implements Serializable { public boolean contains(final int integer) { return getStart() <= integer && integer < getEnd(); } private  Range(final int start, final int end); Range[] partitionWith(final Range other); Range offsetBy(final int offset); static Range withOnly(final int integer); static Range between(final int start, final int end); static Range withLength(final int start, final int length); int getStart(); int getEnd(); int length(); boolean isEmpty(); boolean intersects(final Range other); boolean contains(final int integer); boolean isSubsetOf(final Range other); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj); boolean startsBefore(final Range other); boolean endsBefore(final Range other); boolean endsAfter(final Range other); boolean startsAfter(final Range other); Range[] splitAt(final int integer); Range[] splitAtFromStart(final int length); Range combineWith(Range other); Range expand(int startDelta, int endDelta); Range restrictTo(Range bounds); IntStream stream();  }
@Test public void containsTest() { final int start = 0; final int end = 10; final Range range = Range.between(start, end); assertTrue("start should be contained", range.contains(start)); assertTrue("start-1 should not be contained", !range.contains(start - 1)); assertTrue("end should not be contained", !range.contains(end)); assertTrue("end-1 should be contained", range.contains(end - 1)); assertTrue("[0..10[ contains 5", Range.between(0, 10).contains(5)); assertTrue("empty range does not contain 5", !Range.between(5, 5).contains(5)); }