/** * Creates an instance of {@link ObjectGenerator} which generates each value exactly specified number of times. * Values are generated using weighted distribution until depleted. When all values are generated specified number * of times and {@link ObjectGenerator#next()} is invoked, * {@link io.smartcat.ranger.core.ExactWeightedValue.ExactWeightedValueDepletedException * ExactWeightedValueDepletedException} is thrown. * * @param pairs List of values with corresponding counts. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates each value exactly specified number of times. */ public static <T> ObjectGenerator<T> exactly(List<CountPair<T>> pairs) { return wrap(new ExactWeightedValue<>(unwrapCountPairs(pairs))); }
/** * Creates an instance of {@link ObjectGenerator} which generates each value exactly specified number of times. * Values are generated using weighted distribution until depleted. When all values are generated specified number * of times and {@link ObjectGenerator#next()} is invoked, * {@link io.smartcat.ranger.core.ExactWeightedValue.ExactWeightedValueDepletedException * ExactWeightedValueDepletedException} is thrown. * * @param pairs List of values with corresponding counts. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates each value exactly specified number of times. */ public static <T> ObjectGenerator<T> exactly(List<CountPair<T>> pairs) { return wrap(new ExactWeightedValue<>(unwrapCountPairs(pairs))); }