001package jmri.jmrit.logixng.actions; 002 003import jmri.*; 004 005/** 006 * Enum of common managers. 007 * 008 * @author Daniel Bergqvist (C) 2023 009 */ 010public enum CommonManager { 011 012 Sensors(() -> InstanceManager.getNullableDefault(SensorManager.class), Bundle.getMessage("CommonManager_Sensors")), 013 Turnouts(() -> InstanceManager.getNullableDefault(TurnoutManager.class), Bundle.getMessage("CommonManager_Turnouts")), 014 Lights(() -> InstanceManager.getNullableDefault(LightManager.class), Bundle.getMessage("CommonManager_Lights")), 015 SignalHeads(() -> InstanceManager.getNullableDefault(SignalHeadManager.class), Bundle.getMessage("CommonManager_SignalHeads")), 016 SignalMasts(() -> InstanceManager.getNullableDefault(SignalMastManager.class), Bundle.getMessage("CommonManager_SignalMasts")), 017 Routes(() -> InstanceManager.getNullableDefault(RouteManager.class), Bundle.getMessage("CommonManager_Routes")), 018 Blocks(() -> InstanceManager.getNullableDefault(BlockManager.class), Bundle.getMessage("CommonManager_Blocks")), 019 Reporters(() -> InstanceManager.getNullableDefault(ReporterManager.class), Bundle.getMessage("CommonManager_Reporters")), 020 Memories(() -> InstanceManager.getNullableDefault(MemoryManager.class), Bundle.getMessage("CommonManager_Memories")), 021 Audio(() -> InstanceManager.getNullableDefault(AudioManager.class), Bundle.getMessage("CommonManager_Audio")), 022 LayoutBlocks(() -> InstanceManager.getNullableDefault(jmri.jmrit.display.layoutEditor.LayoutBlockManager.class), Bundle.getMessage("CommonManager_LayoutBlocks")), 023 EntryExit(() -> InstanceManager.getNullableDefault(jmri.jmrit.entryexit.EntryExitPairs.class), Bundle.getMessage("CommonManager_EntryExit")), 024 Warrants(() -> InstanceManager.getNullableDefault(jmri.jmrit.logix.WarrantManager.class), Bundle.getMessage("CommonManager_Warrants")), 025 Sections(() -> InstanceManager.getNullableDefault(SectionManager.class), Bundle.getMessage("CommonManager_Sections")), 026 Transits(() -> InstanceManager.getNullableDefault(TransitManager.class), Bundle.getMessage("CommonManager_Transits")); 027 028 private final String _description; 029 private final GetManager _getManager; 030 private Manager<? extends NamedBean> _manager; 031 032 private CommonManager(GetManager getManager, String description) { 033 _getManager = getManager; 034 _manager = _getManager.getManager(); 035 _description = description; 036 } 037 038 public Manager<? extends NamedBean> getManager() { 039 return _manager; 040 } 041 042 @Override 043 public String toString() { 044 return _description; 045 } 046 047 // This method is used by test classes to reset this enum. 048 // Each test resets the InstanceManager so we need to reset the 049 // managers in this enum. 050 public static void reset() { 051 for (CommonManager manager : CommonManager.values()) { 052 manager._manager = manager._getManager.getManager(); 053 } 054 } 055 056 private interface GetManager { 057 058 Manager<? extends NamedBean> getManager(); 059 } 060 061}