001package jmri.jmrix.lenz.liusbethernet.configurexml;
002
003import jmri.jmrix.configurexml.AbstractNetworkConnectionConfigXml;
004import jmri.jmrix.lenz.liusbethernet.ConnectionConfig;
005import jmri.jmrix.lenz.liusbethernet.LIUSBEthernetAdapter;
006
007/**
008 * Handle XML persistance of layout connections by persistening the LIUSB Server
009 * (and connections). Note this is named as the XML version of a
010 * ConnectionConfig object, but it's actually persisting the LIUSB Server.
011 * <p>
012 * NOTE: The LIUSB Server currently has no options, so this class does not store
013 * any.
014 * <p>
015 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class
016 * is the one actually registered. Reads are brought here directly via the class
017 * attribute in the XML.
018 *
019 * @author Paul Bender Copyright (C) 2011
020 */
021public class ConnectionConfigXml extends AbstractNetworkConnectionConfigXml {
022
023    public ConnectionConfigXml() {
024        super();
025    }
026
027    @Override
028    protected void getInstance() {
029        if (adapter == null) {
030            adapter = new LIUSBEthernetAdapter();
031        }
032    }
033
034    @Override
035    protected void getInstance(Object object) {
036        adapter = ((ConnectionConfig) object).getAdapter();
037    }
038
039    @Override
040    protected void register() {
041        this.register(new ConnectionConfig(adapter));
042    }
043
044}