Package jmri.jmrix

Class DefaultSystemConnectionMemo

    • Field Detail

      • classObjectMap

        protected java.util.Map<java.lang.Class<?>,​java.lang.Object> classObjectMap
    • Method Detail

      • register

        public void register()
        Register with the SystemConnectionMemoManager and InstanceManager with proper ID for later retrieval as a generic system.

        This operation should occur only when the SystemConnectionMemo is ready for use.

        Specified by:
        register in interface SystemConnectionMemo
      • setSystemPrefix

        public final boolean setSystemPrefix​(@Nonnull
                                             java.lang.String systemPrefix)
        Set the system prefix.
        Specified by:
        setSystemPrefix in interface SystemConnectionMemo
        Parameters:
        systemPrefix - prefix to use for this system connection
        Returns:
        true if the system prefix could be set
        Throws:
        java.lang.NullPointerException - if systemPrefix is null
      • getUserName

        public java.lang.String getUserName()
        Provide access to the system user name string.

        This was previously fixed at configuration time.

        Specified by:
        getUserName in interface SystemConnectionMemo
        Returns:
        User name of the connection
      • setUserName

        public final boolean setUserName​(@Nonnull
                                         java.lang.String userName)
        Set the user name for the system connection.
        Specified by:
        setUserName in interface SystemConnectionMemo
        Parameters:
        userName - user name to use for this system connection
        Returns:
        true if the user name could be set.
        Throws:
        java.lang.NullPointerException - if name is null
      • provides

        @OverridingMethodsMustInvokeSuper
        public boolean provides​(java.lang.Class<?> c)
        Check if this connection provides a specific manager type. This method must return false if a manager for the specific type is not provided, and must return true if a manager for the specific type is provided.
        Specified by:
        provides in interface SystemConnectionMemo
        Parameters:
        c - The class type for the manager to be provided
        Returns:
        true if the specified manager is provided
        See Also:
        get(java.lang.Class)
      • dispose

        public void dispose()
        Dispose of System Connection.

        Removes objects from classObjectMap after calling dispose if Disposable. Removes these objects from InstanceManager.

        Specified by:
        dispose in interface Disposable
        Specified by:
        dispose in interface SystemConnectionMemo
      • setDisabled

        public void setDisabled​(boolean disabled)
        Set if the System Connection is currently Disabled.

        disabledAsLoaded is only set once. Sends PropertyChange on change of disabled status.

        Specified by:
        setDisabled in interface SystemConnectionMemo
        Parameters:
        disabled - true to disable, false to enable.
      • getNamedBeanComparator

        public abstract <B extends NamedBean> java.util.Comparator<B> getNamedBeanComparator​(java.lang.Class<B> type)
        Get the Comparator to be used for two NamedBeans. This is typically an NamedBeanComparator, but may be any Comparator that works for this connection type.
        Specified by:
        getNamedBeanComparator in interface SystemConnectionMemo
        Type Parameters:
        B - the type of NamedBean
        Parameters:
        type - the class of NamedBean
        Returns:
        the Comparator
      • isDirty

        public boolean isDirty()
        Get if connection is dirty. Checked fields are disabled, prefix, userName
        Specified by:
        isDirty in interface SystemConnectionMemo
        Returns:
        true if changed since loaded
      • getConsistManager

        public ConsistManager getConsistManager()
        Provide access to the ConsistManager for this particular connection.
        Returns:
        the provided ConsistManager or null if the connection does not provide a ConsistManager
      • store

        public <T> void store​(@Nonnull
                              T item,
                              @Nonnull
                              java.lang.Class<T> type)
        Store a class object to the system connection memo.

        Does NOT register the class with InstanceManager.

        On memo dispose, each class will be removed from InstanceManager, and if the class implements disposable, the dispose method is called.

        Type Parameters:
        T - Class type obtained from item object.
        Parameters:
        item - the class object to store, eg. mySensorManager
        type - Class type, eg. SensorManager.class
      • deregister

        public <T> void deregister​(@Nonnull
                                   T item,
                                   @Nonnull
                                   java.lang.Class<T> type)
        Remove a class object from the system connection memo classObjectMap.

        Does NOT remove the class from InstanceManager.

        Type Parameters:
        T - Class type obtained from item object.
        Parameters:
        item - the class object to store, eg. mySensorManager
        type - Class type, eg. SensorManager.class