001package jmri;
002
003/**
004 * This interface extends {@link jmri.IdTag} to include a locomotive address.
005 * Typical uses are for RailCom and Transponding.  The default assumption is
006 * that the tag ID is a locomotive address.
007 * <hr>
008 * This file is part of JMRI.
009 * <p>
010 * JMRI is free software; you can redistribute it and/or modify it under the
011 * terms of version 2 of the GNU General Public License as published by the Free
012 * Software Foundation. See the "COPYING" file for a copy of this license.
013 * <p>
014 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
015 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
016 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
017 *
018 * @author Paul Bender Copyright (C) 2019
019 * @since 4.15.4
020 */
021public interface AddressedIdTag extends IdTag {
022
023    /**
024     * Gets the address reported back as a {@link jmri.LocoAddress}.
025     *
026     * @return current loco address
027     */
028    default LocoAddress getLocoAddress() {
029        int tagNo = Integer.parseInt(getTagID());
030        return new DccLocoAddress(tagNo, tagNo > 100 );
031    }
032}