@Override protected GENERATE_TYPE doNext() throws GeneratorException { GENERATE_TYPE next; for (int i = 0; i < maxIterations; i++) { next = generator.next(); if (number.gte(next, lowerBoundGenerator.getMin()) && number.lte(next, upperBoundGenerator.getMax())) { return next; } } throw new GeneratorException( format("Random in-range number not found within maxIterations[%s]", maxIterations)); }
NaiveBoundedRangeNumberGenerator( Iterator<GENERATE_TYPE> generator, MinMaxGenerator<GENERATE_TYPE> lowerBoundGenerator, MinMaxGenerator<GENERATE_TYPE> upperBoundGenerator) { this.lowerBoundGenerator = lowerBoundGenerator; this.upperBoundGenerator = upperBoundGenerator; this.generator = generator; this.number = NumberHelper.createNumberHelper(lowerBoundGenerator.getMin().getClass()); }