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

org.opentripplanner.analyst.scenario.ScenarioStore Maven / Gradle / Ivy

package org.opentripplanner.analyst.scenario;

import java.util.HashMap;
import java.util.Map;

/**
 * Retains multiple Scenarios for a single router, keyed on unique IDs.
 */
public class ScenarioStore {

    private int nextId = 0;

    public final Map scenarios = new HashMap<>();

    public Map getDescriptions() {
        Map descriptionForScenarioId = new HashMap<>();
        for (String scenarioId : scenarios.keySet()) {
            descriptionForScenarioId.put(scenarioId, scenarios.get(scenarioId).description);
        }
        return descriptionForScenarioId;
    }

    private synchronized int getNextId() {
        return nextId++;
    }

    public synchronized Scenario getNewEmptyScenario() {
        int id = getNextId();
        Scenario scenario = new Scenario(id);
        scenarios.put(Integer.toString(id), scenario);
        return scenario;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy