@Test public void testFromStartTo(){ assertWithinRange(Range.fromStartTo(3), 1,2,3); assertNotWithinRange(Range.fromStartTo(3), 4,5,6); }
public static Range fromStartTo(final int to){ Assert.assertArgGreaterThan("index must be greater than zero", to, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return "-" + to; } @Override public boolean isWithinRange(int index){return index <= to;} }); }
Range { public static Range fromStartTo(final int to){ Assert.assertArgGreaterThan("index must be greater than zero", to, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return "-" + to; } @Override public boolean isWithinRange(int index){return index <= to;} }); } }
Range { public static Range fromStartTo(final int to){ Assert.assertArgGreaterThan("index must be greater than zero", to, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return "-" + to; } @Override public boolean isWithinRange(int index){return index <= to;} }); } private  Range(); private  Range(final AbstractRange range); }
Range { public static Range fromStartTo(final int to){ Assert.assertArgGreaterThan("index must be greater than zero", to, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return "-" + to; } @Override public boolean isWithinRange(int index){return 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 fromStartTo(final int to){ Assert.assertArgGreaterThan("index must be greater than zero", to, 0); return new Range(new AbstractRange(){ @Override public String toString(){ return "-" + to; } @Override public boolean isWithinRange(int index){return 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);  }