RingRange { public BigInteger span(BigInteger ringSize) { if (SegmentGenerator.greaterThanOrEqual(start, end)) { return end.subtract(start).add(ringSize); } else { return end.subtract(start); } } RingRange(BigInteger start, BigInteger end);  RingRange(String... range); BigInteger getStart(); BigInteger getEnd(); BigInteger span(BigInteger ringSize); boolean encloses(RingRange other); @JsonIgnore boolean isWrapping(); @Override String toString(); static RingRange merge(List<RingRange> ranges); static final Comparator<RingRange> START_COMPARATOR; }
@Test public void testSpan() throws Exception { RingRange r0To20 = new RingRange(BigInteger.valueOf(0L), BigInteger.valueOf(20L)); BigInteger ringSize200 = BigInteger.valueOf(200L); assertEquals(20, r0To20.span(ringSize200).intValue()); RingRange r20To0 = new RingRange(BigInteger.valueOf(20L), BigInteger.valueOf(0L)); assertEquals(180, r20To0.span(ringSize200).intValue()); }