001package jmri;
002
003/**
004 * Interface for generic Locomotive Address.
005 *
006 * Note that this is not DCC-specific.
007 *
008 *
009 * <hr>
010 * This file is part of JMRI.
011 * <p>
012 * JMRI is free software; you can redistribute it and/or modify it under the
013 * terms of version 2 of the GNU General Public License as published by the Free
014 * Software Foundation. See the "COPYING" file for a copy of this license.
015 * <p>
016 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
017 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
018 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
019 *
020 * @author Bob Jacobsen Copyright (C) 2005
021 */
022@javax.annotation.concurrent.Immutable
023public interface LocoAddress {
024
025    int getNumber();
026
027    Protocol getProtocol();
028
029    default boolean isConsistAddress() { return false; }
030    
031    enum Protocol {
032
033        DCC_SHORT("dcc_short", "ProtocolDCC_Short"), // NOI18N
034        DCC_LONG("dcc_long", "ProtocolDCC_Long"), // NOI18N
035        DCC("dcc", "ProtocolDCC"), // NOI18N
036        SELECTRIX("selectrix", "ProtocolSelectrix"), // NOI18N
037        MOTOROLA("motorola", "ProtocolMotorola"), // NOI18N
038        MFX("mfx", "ProtocolMFX"), // NOI18N
039        M4("m4", "ProtocolM4"), // NOI18N
040        OPENLCB("openlcb", "ProtocolOpenLCB"), // NOI18N
041        TMCC1("tmcc1", "ProtocolTMCC1"), // NOI18N
042        TMCC2("tmcc2", "ProtocolTMCC2"), // NOI18N
043        LGB("lgb", "ProtocolLGB");   // NOI18N
044
045        Protocol(String shName, String peopleKey) {
046            this.shortName = shName;
047            this.peopleName = Bundle.getMessage(peopleKey);
048        }
049
050        String shortName;
051        String peopleName;
052        boolean isConsist = false;
053        
054        public String getShortName() {
055            return shortName;
056        }
057
058        public String getPeopleName() {
059            return peopleName;
060        }
061
062        static public Protocol getByShortName(String shName) {
063            for (Protocol p : Protocol.values()) {
064                if (p.shortName.equals(shName)) {
065                    return p;
066                }
067            }
068            throw new java.lang.IllegalArgumentException("argument value " + shName + " not valid");
069        }
070
071        static public Protocol getByPeopleName(String pName) {
072            for (Protocol p : Protocol.values()) {
073                if (p.peopleName.equals(pName)) {
074                    return p;
075                }
076            }
077            throw new java.lang.IllegalArgumentException("argument value " + pName + " not valid");
078        }
079
080    }
081
082}