001package jmri.managers;
002
003import javax.annotation.Nonnull;
004import jmri.Manager;
005import jmri.StringIO;
006import jmri.StringIOManager;
007
008/**
009 * Implementation of a StringIOManager that can serve as a proxy for multiple
010 * system-specific implementations.
011 *
012 * @author  Bob Jacobsen      Copyright (C) 2010, 2018 2024
013 * @author  Dave Duchamp      Copyright (C) 2004
014 * @author  Daniel Bergqvist  Copyright (C) 2020
015 */
016public class ProxyStringIOManager extends AbstractProvidingProxyManager<StringIO>
017        implements StringIOManager {
018
019    public ProxyStringIOManager() {
020        super();
021    }
022
023    @Override
024    public int getXMLOrder() {
025        return jmri.Manager.STRINGIOS;
026    }
027
028    @Override
029    protected AbstractManager<StringIO> makeInternalManager() {
030        return jmri.InstanceManager.getDefault(jmri.jmrix.internal.InternalSystemConnectionMemo.class).getStringIOManager();
031    }
032
033    /** {@inheritDoc} */
034    @Override
035    @Nonnull
036    protected StringIO makeBean(Manager<StringIO> manager, String systemName, String userName) throws IllegalArgumentException {
037        var retval = ((StringIOManager) manager).newStringIO(systemName, userName);
038        log.trace("makeBean returns {}", retval);
039        return retval;
040    }
041
042    /** {@inheritDoc} */
043    @Override
044    public StringIO getStringIO(@Nonnull String name) {
045        return super.getNamedBean(name);
046    }
047
048    /** {@inheritDoc} */
049    @Override
050    @Nonnull
051    public StringIO newStringIO(@Nonnull String systemName, String userName) throws IllegalArgumentException {
052        return newNamedBean(systemName, userName);
053    }
054
055    @Override
056    @Nonnull
057    public String getBeanTypeHandled(boolean plural) {
058        return Bundle.getMessage(plural ? "BeanNameStringIOs" : "BeanNameStringIO");
059    }
060
061    @Override
062    @Nonnull
063    public StringIO provideStringIO(@Nonnull String sName) throws IllegalArgumentException {
064        return super.provideNamedBean(sName);
065    }
066
067    /** {@inheritDoc} */
068    @Override
069    @Nonnull
070    public StringIO provide(@Nonnull String name) throws IllegalArgumentException { 
071        return provideStringIO(name); 
072    }
073
074    /**
075     * {@inheritDoc}
076     */
077    @Override
078    public Class<StringIO> getNamedBeanClass() {
079        return StringIO.class;
080    }
081
082    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ProxyStringIOManager.class);
083
084}