All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geolatte.geom.generator.Choice Maven / Gradle / Ivy

Go to download

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy