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

com.github.rawls238.scientist4j.ExperimentBuilder Maven / Gradle / Ivy

The newest version!
package com.github.rawls238.scientist4j;

import com.github.rawls238.scientist4j.metrics.MetricsProvider;

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 MetricsProvider metricsProvider;
    private BiFunction comparator;
    private Map context;
    private ExecutorService executorService;

    public ExperimentBuilder() {
        context = new HashMap<>();
        comparator = Object::equals;
    }

    public ExperimentBuilder withName(final String name) {
        this.name = name;
        return this;
    }

    public ExperimentBuilder withMetricsProvider(final MetricsProvider metricsProvider) {
        this.metricsProvider = metricsProvider;
        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;
        assert metricsProvider != null;
        return new Experiment<>(name, context, false, metricsProvider, comparator,
            executorService);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy