Package jmri.jmrix

Class SystemConnectionMemoManager

    • Field Detail

      • CONNECTION_ADDED

        public static final java.lang.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:
        Constant Field Values
      • CONNECTION_REMOVED

        public static final java.lang.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:
        Constant Field Values
    • Method Detail

      • register

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

        @CheckForNull
        public SystemConnectionMemo getSystemConnectionMemo​(@Nonnull
                                                            java.lang.String systemPrefix,
                                                            @Nonnull
                                                            java.lang.String userName)
        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.
      • isUserNameAvailable

        public boolean isUserNameAvailable​(@Nonnull
                                           java.lang.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
                                               java.lang.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
      • getConnection

        @CheckForNull
        public static <T extends SystemConnectionMemo> T getConnection​(@Nonnull
                                                                       java.lang.String systemConnectionName,
                                                                       @Nonnull
                                                                       java.lang.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
                                                                                 java.lang.String userName,
                                                                                 @Nonnull
                                                                                 java.lang.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