Package jmri.jmrix
Class SystemConnectionMemoManager
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.jmrix.SystemConnectionMemoManager
-
- All Implemented Interfaces:
BeanInterface
,PropertyChangeFirer
,PropertyChangeProvider
,InstanceManagerAutoDefault
public class SystemConnectionMemoManager extends Bean implements 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 Summary
Fields Modifier and Type Field Description static java.lang.String
CONNECTION_ADDED
Property name change fired when a connection is registered.static java.lang.String
CONNECTION_REMOVED
Property name change fired when a connection is deregistered.-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description SystemConnectionMemoManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deregister(SystemConnectionMemo memo)
static <T extends SystemConnectionMemo>
TgetConnection(java.lang.String systemConnectionName, java.lang.Class<T> clazz)
Find the connection by its name.static <T extends SystemConnectionMemo>
TgetConnectionByUserName(java.lang.String userName, java.lang.Class<T> clazz)
Find the connection by its user name.static SystemConnectionMemoManager
getDefault()
Get the default instance of this manager.SystemConnectionMemo
getSystemConnectionMemo(java.lang.String systemPrefix, java.lang.String userName)
For a given System UserName AND System Prefix, get the Connection Memo.SystemConnectionMemo
getSystemConnectionMemoForSystemPrefix(java.lang.String systemPrefix)
For a given System Prefix, get the Connection Memo.SystemConnectionMemo
getSystemConnectionMemoForUserName(java.lang.String userName)
For a given System UserName, get the Connection Memo.boolean
isSystemPrefixAvailable(java.lang.String systemPrefix)
Check if a system connection prefix for the system names of other objects is available to be used.boolean
isUserNameAvailable(java.lang.String userName)
Check if a system connection user name is available to be used.void
register(SystemConnectionMemo memo)
Register a SystemConnectionMemo in the InstanceManager.-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
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
-
-
Constructor Detail
-
SystemConnectionMemoManager
public SystemConnectionMemoManager()
-
-
Method Detail
-
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
@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.
-
getSystemConnectionMemoForUserName
@CheckForNull public SystemConnectionMemo getSystemConnectionMemoForUserName(@Nonnull java.lang.String userName)
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
@CheckForNull public SystemConnectionMemo getSystemConnectionMemoForSystemPrefix(@Nonnull java.lang.String systemPrefix)
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 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
-
getDefault
public static SystemConnectionMemoManager 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 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 nameclazz
- 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 nameclazz
- The class of the connection type- Returns:
- The memo if found, null otherwise
-
-