001package jmri.jmrit.logixng.implementation;
002
003import java.util.Arrays;
004import java.util.Set;
005import jmri.InstanceInitializer;
006import jmri.InstanceManager;
007import jmri.implementation.AbstractInstanceInitializer;
008import jmri.jmrit.logixng.StringActionManager;
009import jmri.jmrit.logixng.StringExpressionManager;
010import jmri.jmrix.internal.InternalSystemConnectionMemo;
011import org.openide.util.lookup.ServiceProvider;
012
013/**
014 * Provide the usual default implementations for the
015 * {@link jmri.InstanceManager}.
016 * <P>
017 * Not all {@link jmri.InstanceManager} related classes are provided by this
018 * class. See the discussion in {@link jmri.InstanceManager} of initialization
019 * methods.
020 * <hr>
021 * This file is part of JMRI.
022 * <P>
023 * JMRI is free software; you can redistribute it and/or modify it under the
024 * terms of version 2 of the GNU General Public License as published by the Free
025 * Software Foundation. See the "COPYING" file for a copy of this license.
026 * <P>
027 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
028 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
029 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
030 * <P>
031 * @author Bob Jacobsen Copyright (C) 2001, 2008, 2014
032 * @since 2.9.4
033 */
034@ServiceProvider(service = InstanceInitializer.class)
035public class LogixNG_StringInstanceInitializer extends AbstractInstanceInitializer {
036
037    @Override
038    public <T> Object getDefault(Class<T> type) {
039        
040        // In order for getDefault() to be called for a particular manager,
041        // the manager also needs to be added to the method getInitalizes()
042        // below.
043        
044        if (type == StringActionManager.class) {
045            return new DefaultStringActionManager();
046        }
047
048        if (type == StringExpressionManager.class) {
049            return new DefaultStringExpressionManager();
050        }
051
052        return super.getDefault(type);
053    }
054
055    @Override
056    public Set<Class<?>> getInitalizes() {
057        Set<Class<?>> set = super.getInitalizes();
058        set.addAll(Arrays.asList(
059                StringActionManager.class,
060                StringExpressionManager.class
061        ));
062        return set;
063    }
064
065}