in core/src/main/java/org/apache/commons/functor/range/IntegerRange.java [181:216]
protected Iterator<Integer> createIterator() {
return new Iterator<Integer>() {
private int currentValue;
{
currentValue = leftEndpoint.getValue();
if (leftEndpoint.getBoundType() == BoundType.OPEN) {
this.currentValue += step;
}
}
public void remove() {
throw new UnsupportedOperationException();
}
public Integer next() {
final int step = getStep();
final int r = currentValue;
currentValue += step;
return Integer.valueOf(r);
}
public boolean hasNext() {
final int cmp = Integer.valueOf(currentValue).compareTo(rightEndpoint.getValue());
if (cmp == 0) {
return rightEndpoint.getBoundType() == BoundType.CLOSED;
}
if (step > 0) {
return cmp < 0;
}
return cmp > 0;
}
};
}