org.geolatte.geom.generator.Choice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geolatte-geom Show documentation
Show all versions of geolatte-geom Show documentation
This geoLatte-geom library offers a geometry model that conforms to the OGC Simple Features for SQL
specification.
The newest version!
package org.geolatte.geom.generator;
import java.util.List;
import java.util.Random;
/**
* Created by Karel Maesen, Geovise BVBA on 2019-08-16.
*/
public class Choice implements Generator {
private final List choices;
private final Random rnd;
public static Choice of(List choices) {
return new Choice(choices);
}
public Choice(List choices, Random rnd) {
this.choices = choices;
this.rnd = rnd;
}
public Choice(List choices) {
this(choices, new Random());
}
@Override
public T generate() {
int index = rnd.nextInt(choices.size());
return choices.get(index);
}
}