@Test public void testBetween(){ assertWithinRange(Range.between(3, 6), 3,4,5,6); assertNotWithinRange(Range.between(3, 6), 1,2,7,8,9); }
public static Range between(final int from, final int to){ Assert.assertArgGreaterThan("index must be greater than zero", from, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return from + "-" + to;} @Override public boolean isWithinRange(int index){return from <= index && index <= to;} }); }
Range { public static Range between(final int from, final int to){ Assert.assertArgGreaterThan("index must be greater than zero", from, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return from + "-" + to;} @Override public boolean isWithinRange(int index){return from <= index && index <= to;} }); } }
Range { public static Range between(final int from, final int to){ Assert.assertArgGreaterThan("index must be greater than zero", from, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return from + "-" + to;} @Override public boolean isWithinRange(int index){return from <= index && index <= to;} }); } private  Range(); private  Range(final AbstractRange range); }
Range { public static Range between(final int from, final int to){ Assert.assertArgGreaterThan("index must be greater than zero", from, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return from + "-" + to;} @Override public boolean isWithinRange(int index){return from <= index && index <= to;} }); } private  Range(); private  Range(final AbstractRange range); boolean isWithinRange(final int index); Range andOf(final int... indexes); Range andFromStartTo(final int to); Range andToEndFrom(final int from); Range andBetween(final int from, final int to); @Override String toString(); static Range of(int ... indexes); static Range fromStartTo(final int to); static Range toEndFrom(final int from); static Range between(final int from, final int to); }
Range { public static Range between(final int from, final int to){ Assert.assertArgGreaterThan("index must be greater than zero", from, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return from + "-" + to;} @Override public boolean isWithinRange(int index){return from <= index && index <= to;} }); } private  Range(); private  Range(final AbstractRange range); boolean isWithinRange(final int index); Range andOf(final int... indexes); Range andFromStartTo(final int to); Range andToEndFrom(final int from); Range andBetween(final int from, final int to); @Override String toString(); static Range of(int ... indexes); static Range fromStartTo(final int to); static Range toEndFrom(final int from); static Range between(final int from, final int to);  }