001package jmri.jmrit.logixng.implementation;
002
003import java.util.Arrays;
004import java.util.Set;
005
006import jmri.InstanceInitializer;
007import jmri.implementation.AbstractInstanceInitializer;
008import jmri.jmrit.logixng.*;
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_DigitalInstanceInitializer 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 == DigitalActionManager.class) {
043            return new DefaultDigitalActionManager();
044        }
045
046        if (type == DigitalBooleanActionManager.class) {
047            return new DefaultDigitalBooleanActionManager();
048        }
049
050        if (type == DigitalExpressionManager.class) {
051            return new DefaultDigitalExpressionManager();
052        }
053
054        return super.getDefault(type);
055    }
056
057    @Override
058    public Set<Class<?>> getInitalizes() {
059        Set<Class<?>> set = super.getInitalizes();
060        set.addAll(Arrays.asList(
061                DigitalActionManager.class,
062                DigitalBooleanActionManager.class,
063                DigitalExpressionManager.class
064        ));
065        return set;
066    }
067
068}