Package jmri.jmrix

Class SystemConnectionMemoManager

java.lang.Object
jmri.beans.UnboundBean
jmri.beans.Bean
jmri.jmrix.SystemConnectionMemoManager
All Implemented Interfaces:
BeanInterface, PropertyChangeFirer, PropertyChangeProvider, InstanceManagerAutoDefault

Manager for SystemConnectionMemos. Manages SystemConnectionMemos and SystemConnectionMemo registration with the InstanceManager, ensuring that no two SystemConnectionMemos have the same username or system connection prefix. Also provides an object that other objects can listen to for notification of changes in SystemConnectionMemos.
  • Field Details

    • CONNECTION_ADDED

      public static final String CONNECTION_ADDED
      Property name change fired when a connection is registered. The fired event has a null old value and the added connection as the new value.
      See Also:
    • CONNECTION_REMOVED

      public static final String CONNECTION_REMOVED
      Property name change fired when a connection is deregistered. The fired event has the removed connection as the old value and a null new value.
      See Also:
  • Constructor Details

  • Method Details

    • register

      public void register(SystemConnectionMemo memo)
      Register a SystemConnectionMemo in the InstanceManager.
      Parameters:
      memo - the SystemConnectionMemo to register
    • deregister

      public void deregister(SystemConnectionMemo memo)
    • getSystemConnectionMemo

      For a given System UserName AND System Prefix, get the Connection Memo. Both must match to return the memo.
      Parameters:
      systemPrefix - System Prefix to search for.
      userName - system UserName to search for.
      Returns:
      connection memo, else null if no memo located.
    • getSystemConnectionMemoForUserName

      For a given System UserName, get the Connection Memo.
      Parameters:
      userName - system UserName to search for.
      Returns:
      connection memo, else null if no memo located.
    • getSystemConnectionMemoForSystemPrefix

      For a given System Prefix, get the Connection Memo.
      Parameters:
      systemPrefix - System Prefix to search for.
      Returns:
      connection memo, else null if no memo located.
    • isUserNameAvailable

      public boolean isUserNameAvailable(@Nonnull String userName)
      Check if a system connection user name is available to be used.
      Parameters:
      userName - the user name to check
      Returns:
      true if available; false if already in use
    • isSystemPrefixAvailable

      public boolean isSystemPrefixAvailable(@Nonnull String systemPrefix)
      Check if a system connection prefix for the system names of other objects is available to be used.
      Parameters:
      systemPrefix - the system prefix to check
      Returns:
      true if available; false if already in use
    • getDefault

      Get the default instance of this manager.
      Returns:
      the default instance, created if needed
    • getConnection

      @CheckForNull public static <T extends SystemConnectionMemo> T getConnection(@Nonnull String systemConnectionName, @Nonnull Class<T> clazz)
      Find the connection by its name.

      Example:
      LocoNetSystemConnectionMemo memo = getConnection("L2", LocoNetSystemConnectionMemo.class);

      Type Parameters:
      T - The type of connection
      Parameters:
      systemConnectionName - The connection name
      clazz - The class of the connection type
      Returns:
      The memo if found, null otherwise
    • getConnectionByUserName

      @CheckForNull public static <T extends SystemConnectionMemo> T getConnectionByUserName(@Nonnull String userName, @Nonnull Class<T> clazz)
      Find the connection by its user name.

      Example:
      LocoNetSystemConnectionMemo memo = getConnectionByUserName("LocoNet", LocoNetSystemConnectionMemo.class);

      Type Parameters:
      T - The type of connection
      Parameters:
      userName - The connection user name
      clazz - The class of the connection type
      Returns:
      The memo if found, null otherwise