de.invation.code.toval.misc.valuegeneration.RandomChooser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TOVAL Show documentation
Show all versions of TOVAL Show documentation
TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.
The newest version!
package de.invation.code.toval.misc.valuegeneration;
import java.util.List;
import java.util.Random;
import de.invation.code.toval.validate.ParameterException;
import de.invation.code.toval.validate.Validate;
public class RandomChooser implements ValueChooser {
Random rand = new Random();
@Override
public E chooseValue(List candidates) throws ParameterException {
Validate.notNull(candidates);
Validate.notEmpty(candidates);
return candidates.get(rand.nextInt(candidates.size()));
}
@Override
public boolean isValid() {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy