// Path: datagen/src/main/java/io/qala/datagen/RandomShortApi.java
// public static int integer(int max) {
//     return between(0, max).integer();
// }


import java.util.*;
import static io.qala.datagen.RandomShortApi.integer;
package io.qala.datagen;



@SuppressWarnings({"Convert2Diamond", "WeakerAccess"})
public class RandomElements<T> {
    private final List<T> elements;

    private RandomElements(T[] elements) {
        this(Arrays.asList(elements));
    }

    private RandomElements(Collection<T> elements) {
        this.elements = new ArrayList<T>(elements);
    }

    /**
     * In case you have a collection and then couple of other elements you want to sample from too, but you don't want
     * to create a collection that includes all of them combined.
     *
     * @param elements the collection
     * @param others   other elements you'd like to include into population to sample from
     * @return a random element from all the listed elements/other elements
     */
    @SafeVarargs public static <T> RandomElements<T> from(Collection<T> elements, T... others) {
        Collection<T> coll = new ArrayList<T>(elements);
        coll.addAll(Arrays.asList(others));
        return new RandomElements<T>(coll);
    }

    @SafeVarargs public static <T> RandomElements<T> from(T... elements) {
        return new RandomElements<T>(elements);
    }

    /**
     * Returns random element from the collection.
     *
     * @return a random element from the collection
     */
    public T sample() {
        assertCollectionIsNotEmpty();
// Path: datagen/src/main/java/io/qala/datagen/RandomShortApi.java
// public static int integer(int max) {
//     return between(0, max).integer();
// }


// Path: datagen/src/main/java/io/qala/datagen/RandomElements.java
import java.util.*;
import static io.qala.datagen.RandomShortApi.integer;

package io.qala.datagen;



@SuppressWarnings({"Convert2Diamond", "WeakerAccess"})
public class RandomElements<T> {
    private final List<T> elements;

    private RandomElements(T[] elements) {
        this(Arrays.asList(elements));
    }

    private RandomElements(Collection<T> elements) {
        this.elements = new ArrayList<T>(elements);
    }

    /**
     * In case you have a collection and then couple of other elements you want to sample from too, but you don't want
     * to create a collection that includes all of them combined.
     *
     * @param elements the collection
     * @param others   other elements you'd like to include into population to sample from
     * @return a random element from all the listed elements/other elements
     */
    @SafeVarargs public static <T> RandomElements<T> from(Collection<T> elements, T... others) {
        Collection<T> coll = new ArrayList<T>(elements);
        coll.addAll(Arrays.asList(others));
        return new RandomElements<T>(coll);
    }

    @SafeVarargs public static <T> RandomElements<T> from(T... elements) {
        return new RandomElements<T>(elements);
    }

    /**
     * Returns random element from the collection.
     *
     * @return a random element from the collection
     */
    public T sample() {
        assertCollectionIsNotEmpty();
        int index = integer(size() - 1);