private boolean isValueInBounds(T value) { return (range.isIncreasing() && value.compareTo(range.getEnd()) <= 0) || (range.isDecreasing() && value.compareTo(range.getEnd()) >= 0); }
private boolean isValueInBounds(T value) { return (range.isIncreasing() && value.compareTo(range.getEnd()) <= 0) || (range.isDecreasing() && value.compareTo(range.getEnd()) >= 0); }
/** * Constructs random content string value with specified <code>lengthValue</code> and specified * <code>charRanges</code>. * * @param lengthValue Value that returns integer which represents length of generated string. It should never * generate length that is less than 1. * @param charRanges Ranges of characters from which string will be constructed. */ public RandomContentStringValue(Value<Integer> lengthValue, List<Range<Character>> charRanges) { if (lengthValue == null) { throw new IllegalArgumentException("lengthValue cannot be null."); } this.lengthValue = lengthValue; Set<Character> chars = new HashSet<>(); for (Range<Character> range : charRanges) { if (!range.isIncreasing()) { throw new IllegalArgumentException("All ranges must be increasing."); } for (Character c = range.getBeginning(); c <= range.getEnd(); c++) { chars.add(c); } } possibleCharacters = new ArrayList<>(chars); distribution = new UniformDistribution(); }
/** * Constructs random content string value with specified <code>lengthValue</code> and specified * <code>charRanges</code>. * * @param lengthValue Value that returns integer which represents length of generated string. It should never * generate length that is less than 1. * @param charRanges Ranges of characters from which string will be constructed. */ public RandomContentStringValue(Value<Integer> lengthValue, List<Range<Character>> charRanges) { if (lengthValue == null) { throw new IllegalArgumentException("lengthValue cannot be null."); } this.lengthValue = lengthValue; Set<Character> chars = new HashSet<>(); for (Range<Character> range : charRanges) { if (!range.isIncreasing()) { throw new IllegalArgumentException("All ranges must be increasing."); } for (Character c = range.getBeginning(); c <= range.getEnd(); c++) { chars.add(c); } } possibleCharacters = new ArrayList<>(chars); distribution = new UniformDistribution(); }
/** * Constructs range value with specified <code>range</code>, <code>useEdgeCases</code> and * <code>distribution</code>. * * @param range Range. * @param useEdgeCases Indicates whether to create edge cases as first two values or not. * @param distribution Distribution to use for value selection. */ public RangeValue(Range<T> range, boolean useEdgeCases, Distribution distribution) { if (range == null) { throw new IllegalArgumentException("Range cannot be null."); } if (!range.isIncreasing()) { throw new InvalidRangeBoundsException("End of the range must be greater than the beginning of the range."); } if (distribution == null) { throw new IllegalArgumentException("Distribution cannot be null."); } this.beginning = range.getBeginning(); this.end = range.getEnd(); this.useEdgeCases = useEdgeCases; this.distribution = distribution; }
/** * Constructs range value with specified <code>range</code>, <code>useEdgeCases</code> and * <code>distribution</code>. * * @param range Range. * @param useEdgeCases Indicates whether to create edge cases as first two values or not. * @param distribution Distribution to use for value selection. */ public RangeValue(Range<T> range, boolean useEdgeCases, Distribution distribution) { if (range == null) { throw new IllegalArgumentException("Range cannot be null."); } if (!range.isIncreasing()) { throw new InvalidRangeBoundsException("End of the range must be greater than the beginning of the range."); } if (distribution == null) { throw new IllegalArgumentException("Distribution cannot be null."); } this.beginning = range.getBeginning(); this.end = range.getEnd(); this.useEdgeCases = useEdgeCases; this.distribution = distribution; }
/** * 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."); } }