Class OBlockManager

    • Method Detail

      • getXMLOrder

        public int getXMLOrder()
        Description copied from interface: Manager
        Determine the order that types should be written when storing panel files. Uses one of the constants defined in this class.

        Yes, that's an overly-centralized methodology, but it works for now.

        Specified by:
        getXMLOrder in interface Manager<OBlock>
        Returns:
        write order for this Manager; larger is later.
      • createNewOBlock

        @CheckForNull
        public OBlock createNewOBlock​(@Nonnull
                                      java.lang.String systemName,
                                      @CheckForNull
                                      java.lang.String userName)
        Create a new OBlock if it does not exist.
        Parameters:
        systemName - System name
        userName - User name
        Returns:
        newly created OBlock, or null if an OBlock with the same systemName or userName already exists, or if there is trouble creating a new OBlock
      • createNewOBlock

        @CheckForNull
        public OBlock createNewOBlock​(@Nonnull
                                      java.lang.String userName)
        Create a new OBlock using an automatically incrementing system name.
        Parameters:
        userName - the user name for the new OBlock
        Returns:
        null if an OBlock with the same systemName or userName already exists, or if there is trouble creating a new OBlock.
      • getOBlock

        public OBlock getOBlock​(@Nonnull
                                java.lang.String name)
        Get an existing OBlock by a given name. First looks up assuming that name is a User Name. If this fails looks up assuming that name is a System Name. If both fail, returns null.
        Parameters:
        name - OBlock name
        Returns:
        the OBlock, oe null if not found
      • provide

        public OBlock provide​(@Nonnull
                              java.lang.String name)
        Description copied from interface: ProvidingManager
        Get an existing instance via user name, then system name; if no matching instance is found, create a new NameBean from the system name.

        If the name is a valid system name, it will be used for the new NamedBean. Otherwise, the Manager.makeSystemName(java.lang.String) method will attempt to turn it into a valid system name which the manager will attempt to use. If that fails, an exception is thrown.

        This is similar to the specific methods found in certain type-specific managers: TurnoutManager.provideTurnout(java.lang.String), SensorManager.provideSensor(java.lang.String), et al. Those might be more mnemonic; this one is more generic. Neither is preferred nor deprecated; use your choice.

        Specified by:
        provide in interface ProvidingManager<OBlock>
        Parameters:
        name - User name, system name, or address which can be promoted to system name
        Returns:
        Never null
      • getBeanTypeHandled

        @Nonnull
        public java.lang.String getBeanTypeHandled​(boolean plural)
        Description copied from interface: Manager
        Get the user-readable name of the type of NamedBean handled by this manager.

        For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.

        Specified by:
        getBeanTypeHandled in interface Manager<OBlock>
        Parameters:
        plural - true to return plural form of the type; false to return singular form
        Returns:
        a string of the bean type that the manager handles, eg Turnout, Sensor etc
      • getNamedBeanClass

        public java.lang.Class<OBlockgetNamedBeanClass()
        Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.
        Specified by:
        getNamedBeanClass in interface Manager<OBlock>
        Returns:
        the class supported by this Manager.