001package jmri.jmrix.bachrus.speedmatcher.basic;
002
003import jmri.jmrix.bachrus.speedmatcher.SpeedMatcher;
004
005/**
006 * Factory for creating the correct type of Basic speed matcher for the given
007 * SpeedMatcherConfig
008 *
009 * @author Todd Wegter Copyright (C) 2024
010 */
011public class BasicSpeedMatcherFactory {
012
013    /**
014     * Gets the correct Basic Speed Matcher for the given speedTable
015     *
016     * @param speedTable BasicSpeedMatcherConfig.SpeedTable to use for speed
017     *                   matching
018     * @param config     BasicSpeedMatcherConfig for initializing the speed
019     *                   matcher
020     * @return the SpeedMatcher to use for speed matching
021     */
022    public static SpeedMatcher getSpeedMatcher(BasicSpeedMatcherConfig.SpeedTable speedTable, BasicSpeedMatcherConfig config) {
023
024        switch (speedTable) {
025            case ESU:
026                return new BasicESUTableSpeedMatcher(config);
027            case ADVANCED:
028                return new BasicSpeedTableSpeedMatcher(config);
029            default:
030                return new BasicSimpleCVSpeedMatcher(config);
031        }
032    }
033}