@Override protected void eval() { T nextValue = peekNextValue(); if (isValueInBounds(nextValue)) { val = nextValue; } else { val = range.getBeginning(); } }
/** * Constructs circular range value with specified <code>range</code> and <code>increment</code>. * * @param range Range. * @param increment Increment. */ public CircularRangeValue(Range<T> range, T increment) { if (range == null) { throw new IllegalArgumentException("Range cannot be null."); } if (increment == null || increment.compareTo(zero()) == 0) { throw new IllegalArgumentException("Increment cannot be null nor zero."); } if (range.isEmpty()) { throw new IllegalArgumentException("Range cannot be empty."); } if (range.isIncreasing() && increment.compareTo(zero()) < 0) { throw new IllegalArgumentException("If range is increasing, increment must be positive."); } if (range.isDecreasing() && increment.compareTo(zero()) > 0) { throw new IllegalArgumentException("If range is decreasing, increment must be negative."); } this.range = range; this.increment = increment; this.val = range.getBeginning(); this.evaluated = true; if (isIncrementGreaterThanRangeSize()) { throw new IllegalArgumentException("Range size must be greater than increment."); } }
/** * Constructs circular range value with specified <code>range</code> and <code>increment</code>. * * @param range Range. * @param increment Increment. */ public CircularRangeValue(Range<T> range, T increment) { if (range == null) { throw new IllegalArgumentException("Range cannot be null."); } if (increment == null || increment.compareTo(zero()) == 0) { throw new IllegalArgumentException("Increment cannot be null nor zero."); } if (range.isEmpty()) { throw new IllegalArgumentException("Range cannot be empty."); } if (range.isIncreasing() && increment.compareTo(zero()) < 0) { throw new IllegalArgumentException("If range is increasing, increment must be positive."); } if (range.isDecreasing() && increment.compareTo(zero()) > 0) { throw new IllegalArgumentException("If range is decreasing, increment must be negative."); } this.range = range; this.increment = increment; this.val = range.getBeginning(); this.evaluated = true; if (isIncrementGreaterThanRangeSize()) { throw new IllegalArgumentException("Range size must be greater than increment."); } }
@Override protected void eval() { T nextValue = peekNextValue(); if (isValueInBounds(nextValue)) { val = nextValue; } else { val = range.getBeginning(); } }