| 516 | } |
| 517 | |
| 518 | private Comparable peek() { |
| 519 | if (step > 0) { |
| 520 | Comparable peekValue = value; |
| 521 | for (int i = 0; i < step; i++) { |
| 522 | peekValue = (Comparable) range.increment(peekValue); |
| 523 | // handle back to beginning due to modulo incrementing |
| 524 | if (range.compareTo(peekValue, range.from) <= 0) return null; |
| 525 | } |
| 526 | if (range.compareTo(peekValue, range.to) <= 0) { |
| 527 | return peekValue; |
| 528 | } |
| 529 | } else { |
| 530 | final int positiveStep = -step; |
| 531 | Comparable peekValue = value; |
| 532 | for (int i = 0; i < positiveStep; i++) { |
| 533 | peekValue = (Comparable) range.decrement(peekValue); |
| 534 | // handle back to beginning due to modulo decrementing |
| 535 | if (range.compareTo(peekValue, range.to) >= 0) return null; |
| 536 | } |
| 537 | if (range.compareTo(peekValue, range.from) >= 0) { |
| 538 | return peekValue; |
| 539 | } |
| 540 | } |
| 541 | return null; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | /** |