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.DigitalExpressionFactory; 010import jmri.jmrit.logixng.DigitalExpressionBean; 011 012import org.openide.util.lookup.ServiceProvider; 013 014/** 015 * The factory for LogixNG LocoNet classes. 016 */ 017@ServiceProvider(service = DigitalExpressionFactory.class) 018public class ExpressionFactory implements DigitalExpressionFactory { 019 020 @Override 021 public void init() { 022 CategoryLocoNet.registerCategory(); 023 } 024 025 @Override 026 public Set<Map.Entry<Category, Class<? extends DigitalExpressionBean>>> getExpressionClasses() { 027 Set<Map.Entry<Category, Class<? extends DigitalExpressionBean>>> expressionClasses = 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 expressionClasses.add(new AbstractMap.SimpleEntry<>(CategoryLocoNet.LOCONET, ExpressionSlotUsage.class)); 032 } 033 034 return expressionClasses; 035 } 036 037 038 039 public static final class LocoNet extends Category { 040 041 public LocoNet() { 042 super("LOCONET", Bundle.getMessage("MenuLocoNet"), 1100); 043 } 044 } 045 046}