001package jmri.jmrit.beantable.routetable;
002
003import jmri.Route;
004import jmri.Turnout;
005
006import static jmri.jmrit.beantable.routetable.AbstractRouteAddEditFrame.*;
007
008/**
009 * Route Table RouteTurnout Elements.
010 *
011 * Split from {@link jmri.jmrit.beantable.RouteTableAction}
012 *
013 * @author Dave Duchamp Copyright (C) 2004
014 * @author Bob Jacobsen Copyright (C) 2007
015 * @author Simon Reader Copyright (C) 2008
016 * @author Pete Cressman Copyright (C) 2009
017 * @author Egbert Broerse Copyright (C) 2016
018 * @author Paul Bender Copyright (C) 2020
019 */
020class RouteTurnout extends RouteElement {
021
022    RouteTurnout(String sysName, String userName) {
023        super(sysName, userName);
024    }
025
026    @Override
027    String getSetToState() {
028        switch (_setToState) {
029            case Turnout.CLOSED:
030                return SET_TO_CLOSED;
031            case Turnout.THROWN:
032                return SET_TO_THROWN;
033            case Route.TOGGLE:
034                return SET_TO_TOGGLE;
035            default:
036                // fall through
037                break;
038        }
039        return "";
040    }
041
042    @Override
043    void setSetToState(String state) {
044        if (SET_TO_CLOSED.equals(state)) {
045            _setToState = Turnout.CLOSED;
046        } else if (SET_TO_THROWN.equals(state)) {
047            _setToState = Turnout.THROWN;
048        } else if (SET_TO_TOGGLE.equals(state)) {
049            _setToState = Route.TOGGLE;
050        }
051    }
052}