/** * Creates an instance of {@link ObjectGenerator} which generates uniformly distributed values from specified list. * * @param values List of values. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates uniformly distributed values from specified list. */ public static <T> ObjectGenerator<T> random(List<T> values) { return wrap(new DiscreteValue<>(unwrap(values))); }
/** * Creates discrete value. * * @return Instance of {@link DiscreteValue}. */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected DiscreteValue createDiscreteValue() { return peek() instanceof Distribution ? new DiscreteValue((List) pop(1), (Distribution) pop()) : new DiscreteValue((List) pop()); }
/** * Creates discrete value. * * @return Instance of {@link DiscreteValue}. */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected DiscreteValue createDiscreteValue() { return peek() instanceof Distribution ? new DiscreteValue((List) pop(1), (Distribution) pop()) : new DiscreteValue((List) pop()); }
/** * Creates an instance of {@link ObjectGenerator} which generates uniformly distributed values from specified list. * * @param values List of values. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates uniformly distributed values from specified list. */ public static <T> ObjectGenerator<T> random(List<T> values) { return wrap(new DiscreteValue<>(unwrap(values))); }
/** * Creates an instance of {@link ObjectGenerator} which generates values distributed by specified distribution from * specified list. * * @param distribution Distribution to use. * @param values List of values. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates values distributed by specified distribution from * specified list. */ public static <T> ObjectGenerator<T> random(Distribution distribution, List<T> values) { return wrap(new DiscreteValue<>(unwrap(values), distribution)); }
/** * Creates an instance of {@link ObjectGenerator} which generates values distributed by specified distribution from * specified list. * * @param distribution Distribution to use. * @param values List of values. * @param <T> Type instance of {@link ObjectGenerator} will generate. * @return An instance of {@link ObjectGenerator} which generates values distributed by specified distribution from * specified list. */ public static <T> ObjectGenerator<T> random(Distribution distribution, List<T> values) { return wrap(new DiscreteValue<>(unwrap(values), distribution)); }