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