/*
 *    Copyright 2014 Gerard Ryan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package me.grdryn.lisztomania;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomPercentageSubList<E> extends AbstractPercentageSubList<E> {

    public RandomPercentageSubList(final List<E> originalList,
            final double percentage) {

        super(originalList, percentage);

        populateBackingList(originalList, percentage);

    }

    private void populateBackingList(final List<E> inList,
            final double percentage) {

        final Random random = new Random();

        final ArrayList<E> temp = new ArrayList<>(inList);
        while (backingList.size() < percentageSize) {
            backingList.add(temp.remove(random.nextInt(temp.size())));
        }
    }
}

@@ -704,87 +704,1502 @@
 m;%0A%0A
-public class RandomPercentageSubList%3CE%3E extends AbstractPercentageSubList%3CE%3E %7B%0A
+/**%0A * = RandomPercentageSubList%0A *%0A * Use this class to get a %7B@link List%7D of elements picked from an existing%0A * %7B@link List%7D. The chosen elements are randomly selected from %60originalList%60,%0A * with the number of chosen elements decided by the %60percentage%60 parameter to%0A * the %7B@link RandomPercentageSubList#RandomPercentageSubList(List, double)%0A * constructor%7D.%0A *%0A * For example, choosing to get 40%25 from a %7B@link List%7D of 10 elements would%0A * produce a %7B@link List%7D of 4 elements, each chosen from the %60originalList%60:%0A *%0A * %5Bsource,java%5D%0A * --%0A *%0A * import java.util.List;%0A * import me.grdryn.lisztomania.RandomPercentageSubList;%0A *%0A * class MyClass %7B%0A *%0A *     public static void main(String%5B%5D args) %7B%0A *         List%3CInteger%3E tenItems = Arrays.asList(34, -5, 7, 2, 1, 0, 57, -1, 3, 10);%0A *         List%3CInteger%3E fiveAtRandom = new RandomPercentageSubList%3C%3E(tenItems, 40);%0A *%0A *         assert fiveAtRandom.size() == 5;%0A *%0A *         for (Integer item : fiveAtRandom) %7B%0A *             assert tenItems.contains(item);%0A *         %7D%0A *     %7D%0A * %7D%0A *%0A * --%0A *%0A * @author Gerard Ryan%0A */%0Apublic class RandomPercentageSubList%3CE%3E extends AbstractPercentageSubList%3CE%3E %7B%0A%0A    /**%0A     * Creates a List of elements from %60originalList%60 at random, of %60percentage%60%0A     * percent of the %60originalList.%0A     *%0A     * @param originalList%0A     *            The %7B@link List%7D to choose elements from%0A     * @param percentage%0A     *            The percentage of elements from %60originalList%60 to choose%0A     */
 %0A   

Add jAsciidoc to RandomPercentageSubList