001package jmri.jmrit.beantable.routetable;
002
003import jmri.Sensor;
004
005/**
006 * Base class Route Table RouteElements.
007 *
008 * Split from {@link jmri.jmrit.beantable.RouteTableAction}
009 *
010 * @author Dave Duchamp Copyright (C) 2004
011 * @author Bob Jacobsen Copyright (C) 2007
012 * @author Simon Reader Copyright (C) 2008
013 * @author Pete Cressman Copyright (C) 2009
014 * @author Egbert Broerse Copyright (C) 2016
015 * @author Paul Bender Copyright (C) 2020
016 */
017abstract class RouteElement {
018
019    private final String _sysName;
020    private final String _userName;
021    private boolean _included;
022    int _setToState;
023
024    RouteElement(String sysName, String userName) {
025        _sysName = sysName;
026        _userName = userName;
027        _included = false;
028        _setToState = Sensor.INACTIVE;
029    }
030
031    String getSysName() {
032        return _sysName;
033    }
034
035    String getUserName() {
036        return _userName;
037    }
038
039    boolean isIncluded() {
040        return _included;
041    }
042
043    String getDisplayName() {
044        String name = getUserName();
045        if (name != null && name.length() > 0) {
046            return name;
047        } else {
048            return getSysName();
049        }
050
051    }
052
053    void setIncluded(boolean include) {
054        _included = include;
055    }
056
057    abstract String getSetToState();
058
059    abstract void setSetToState(String state);
060
061    int getState() {
062        return _setToState;
063    }
064
065    void setState(int state) {
066        _setToState = state;
067    }
068
069}