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