com.github.rawls238.scientist4j.ExperimentBuilder Maven / Gradle / Ivy
package com.github.rawls238.scientist4j;
import io.dropwizard.metrics5.MetricRegistry;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.function.BiFunction;
public class ExperimentBuilder {
private String name;
private MetricRegistry registry;
private BiFunction comparator;
private Map context;
private ExecutorService executorService;
public ExperimentBuilder() {
context = new HashMap<>();
comparator = Object::equals;
registry = new MetricRegistry();
}
public ExperimentBuilder withName(final String name) {
this.name = name;
return this;
}
public ExperimentBuilder withRegistry(final MetricRegistry registry) {
this.registry = registry;
return this;
}
public ExperimentBuilder withComparator(final BiFunction comparator) {
this.comparator = comparator;
return this;
}
public ExperimentBuilder withExecutorService(ExecutorService executorService) {
this.executorService = executorService;
return this;
}
public Experiment build() {
assert name != null;
return new Experiment<>(name, context, false, registry, comparator,
executorService);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy