Package jmri.managers

Class AbstractLightManager

All Implemented Interfaces:
PropertyChangeListener, VetoableChangeListener, EventListener, PropertyChangeFirer, PropertyChangeProvider, SilenceablePropertyChangeProvider, VetoableChangeFirer, VetoableChangeProvider, LightManager, Manager<Light>, ProvidingManager<Light>
Direct Known Subclasses:
AcelaLightManager, CbusLightManager, DCCppLightManager, InternalLightManager, IpocsLightManager, JMRIClientLightManager, LnLightManager, MqttLightManager, NceLightManager, OlcbLightManager, SerialLightManager, SerialLightManager, SerialLightManager, SerialLightManager, SerialLightManager, SerialLightManager, UsbLightManager, XBeeLightManager, XNetLightManager

public abstract class AbstractLightManager
extends AbstractManager<Light>
implements LightManager
Abstract partial implementation of a LightManager.

Based on AbstractSignalHeadManager.java and AbstractSensorManager.java

  • Constructor Details

  • Method Details

    • getXMLOrder

      public int getXMLOrder()
      Determine the order that types should be written when storing panel files. Uses one of the constants defined in this class.

      Yes, that's an overly-centralized methodology, but it works for now.

      Specified by:
      getXMLOrder in interface Manager<Light>
      Returns:
      write order for this Manager; larger is later.
    • typeLetter

      public char typeLetter()
      Specified by:
      typeLetter in interface Manager<Light>
      Returns:
      The type letter for a specific implementation
    • provideLight

      Get the Light with the user name, then system name if needed; if that fails, create a new Light. If the name is a valid system name, it will be used for the new Light. Otherwise, the Manager.makeSystemName(java.lang.String) method will attempt to turn it into a valid system name.

      This provides the same function as ProvidingManager.provide(java.lang.String) which has a more generic form.

      Specified by:
      provideLight in interface LightManager
      Parameters:
      name - User name, system name, or address which can be promoted to system name
      Returns:
      Never null under normal circumstances
    • getLight

      Get an existing Light or return null if it doesn't exist. Locates via user name, then system name if needed.
      Specified by:
      getLight in interface LightManager
      Parameters:
      name - User name, system name, or address which can be promoted to system name
      Returns:
      Never null
    • newLight

      @Nonnull public Light newLight​(@Nonnull String systemName, @CheckForNull String userName)
      Return a Light with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one Light object representing a given physical Light and therefore only one with a specific system or user name.

      This will always return a valid object reference; a new object will be created if necessary. In that case:

      • If a null reference is given for user name, no user name will be associated with the Light object created; a valid system name must be provided
      • If both names are provided, the system name defines the hardware access of the desired sensor, and the user address is associated with it. The system name must be valid.
      Note that it is possible to make an inconsistent request if both addresses are provided, but the given values are associated with different objects. This is a problem, and we don't have a good solution except to issue warnings. This will mostly happen if you're creating Lights when you should be looking them up.
      Specified by:
      newLight in interface LightManager
      Parameters:
      systemName - the desired system name
      userName - the desired user name
      Returns:
      requested Light object (never null)
    • createNewLight

      @CheckForNull protected abstract Light createNewLight​(@Nonnull String systemName, String userName)
      Internal method to invoke the factory, after all the logic for returning an existing Light has been invoked.
      Parameters:
      systemName - the system name to use for this light
      userName - the user name to use for this light
      Returns:
      the new light or null if unsuccessful
    • activateAllLights

      public void activateAllLights()
      Activate the control mechanism for each Light controlled by this LightManager. Note that some Lights don't require any activation. The activateLight method in AbstractLight.java determines what needs to be done for each Light.
      Specified by:
      activateAllLights in interface LightManager
    • convertSystemNameToAlternate

      Convert the system name to a normalized alternate name.

      This routine is to allow testing to ensure that two Lights with alternate names that refer to the same output bit are not created.

      This routine is implemented in AbstractLightManager to return "". If a system implementation has alternate names, the system specific Light Manager should override this routine and supply the alternate name.

      Specified by:
      convertSystemNameToAlternate in interface LightManager
      Parameters:
      systemName - the system name to convert
      Returns:
      an alternate name
    • supportsVariableLights

      public boolean supportsVariableLights​(@Nonnull String systemName)
      Test if system in the given name can support a variable light.
      Specified by:
      supportsVariableLights in interface LightManager
      Parameters:
      systemName - the system name
      Returns:
      true if variable lights are supported; false otherwise
    • allowMultipleAdditions

      public boolean allowMultipleAdditions​(@Nonnull String systemName)
      Test if possible to generate multiple lights given a numerical range to complete the system name.
      Specified by:
      allowMultipleAdditions in interface LightManager
      Parameters:
      systemName - the system name
      Returns:
      true if multiple lights can be created at once; false otherwise
    • getBeanTypeHandled

      @Nonnull public String getBeanTypeHandled​(boolean plural)
      Get bean type handled.
      Specified by:
      getBeanTypeHandled in interface Manager<Light>
      Parameters:
      plural - true to return plural form of the type; false to return singular form
      Returns:
      a string for the type of object handled by this manager
    • getNamedBeanClass

      Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.
      Specified by:
      getNamedBeanClass in interface Manager<Light>
      Returns:
      the class supported by this Manager.
    • getEntryToolTip

      Get a manager-specific tool tip for adding an entry to the manager.
      Specified by:
      getEntryToolTip in interface Manager<Light>
      Returns:
      the tool tip or null to disable the tool tip