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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringProperty name change fired when a connection is registered.static final StringProperty name change fired when a connection is deregistered.Fields inherited from class jmri.beans.Bean
propertyChangeSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic <T extends SystemConnectionMemo>
TgetConnection(String systemConnectionName, Class<T> clazz) Find the connection by its name.static <T extends SystemConnectionMemo>
TgetConnectionByUserName(String userName, Class<T> clazz) Find the connection by its user name.static SystemConnectionMemoManagerGet the default instance of this manager.getSystemConnectionMemo(String systemPrefix, String userName) For a given System UserName AND System Prefix, get the Connection Memo.getSystemConnectionMemoForSystemPrefix(String systemPrefix) For a given System Prefix, get the Connection Memo.getSystemConnectionMemoForUserName(String userName) For a given System UserName, get the Connection Memo.booleanisSystemPrefixAvailable(String systemPrefix) Check if a system connection prefix for the system names of other objects is available to be used.booleanisUserNameAvailable(String userName) Check if a system connection user name is available to be used.voidregister(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, removePropertyChangeListenerMethods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
Field Details
-
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
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
-
SystemConnectionMemoManager
public SystemConnectionMemoManager()
-
-
Method Details
-
register
Register a SystemConnectionMemo in the InstanceManager.- Parameters:
memo- the SystemConnectionMemo to register
-
deregister
-
getSystemConnectionMemo
@CheckForNull public SystemConnectionMemo getSystemConnectionMemo(@Nonnull String systemPrefix, @Nonnull 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 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 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
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
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 nameclazz- 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 nameclazz- The class of the connection type- Returns:
- The memo if found, null otherwise
-