001package jmri.jmrix.loconet.logixng;
002
003import java.util.AbstractMap;
004import java.util.HashSet;
005import java.util.Map;
006import java.util.Set;
007
008import jmri.jmrit.logixng.Category;
009import jmri.jmrit.logixng.DigitalActionFactory;
010import jmri.jmrit.logixng.DigitalActionBean;
011
012import org.openide.util.lookup.ServiceProvider;
013
014/**
015 * The factory for LogixNG LocoNet classes.
016 */
017@ServiceProvider(service = DigitalActionFactory.class)
018public class ActionFactory implements DigitalActionFactory {
019
020    @Override
021    public void init() {
022        CategoryLocoNet.registerCategory();
023    }
024
025    @Override
026    public Set<Map.Entry<Category, Class<? extends DigitalActionBean>>> getActionClasses() {
027        Set<Map.Entry<Category, Class<? extends DigitalActionBean>>> actionClasses = new HashSet<>();
028
029        // We don't want to add these classes if we don't have a LocoNet connection
030        if (CategoryLocoNet.hasLocoNet()) {
031            actionClasses.add(new AbstractMap.SimpleEntry<>(CategoryLocoNet.LOCONET, ActionClearSlots.class));
032            actionClasses.add(new AbstractMap.SimpleEntry<>(CategoryLocoNet.LOCONET, ActionUpdateSlots.class));
033            actionClasses.add(new AbstractMap.SimpleEntry<>(CategoryLocoNet.LOCONET, SetSpeedZero.class));
034        }
035
036        return actionClasses;
037    }
038
039}