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