Package jmri.managers

Class DefaultRouteManager

    • 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<Route>
        Returns:
        write order for this Manager; larger is later.
      • provideRoute

        @Nonnull
        public Route provideRoute​(@Nonnull
                                  java.lang.String systemName,
                                  @CheckForNull
                                  java.lang.String userName)
                           throws java.lang.IllegalArgumentException
        Provides existing Route by UserName then SystemName if one exists. Create a new Route if the route does not exist.
        Specified by:
        provideRoute in interface RouteManager
        Parameters:
        systemName - the system name for the route
        userName - the user name for the route
        Returns:
        New or existing Route.
        Throws:
        java.lang.IllegalArgumentException - if there is trouble creating a new Route
      • newRoute

        @Nonnull
        public Route newRoute​(@Nonnull
                              java.lang.String userName)
                       throws java.lang.IllegalArgumentException
        Create a new Route if the route does not exist. Intended for use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.

        Calls provideRoute(String, String) with the result of AbstractManager.getAutoSystemName() as the system name.

        Specified by:
        newRoute in interface RouteManager
        Parameters:
        userName - user name for the new route
        Returns:
        New Route.
        Throws:
        java.lang.IllegalArgumentException - if there is trouble creating a new Route
      • getRoute

        @CheckForNull
        public Route getRoute​(@Nonnull
                              java.lang.String name)
        Method to get an existing Route. First looks up assuming that name is a User Name. If this fails looks up assuming that name is a System Name.
        Specified by:
        getRoute in interface RouteManager
        Parameters:
        name - User name or system name to match
        Returns:
        If both fail, returns 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<Route>
        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<RoutegetNamedBeanClass()
        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<Route>
        Returns:
        the class supported by this Manager.
      • provide

        @Nonnull
        public Route provide​(@Nonnull
                             java.lang.String name)
                      throws java.lang.IllegalArgumentException
        Provide Route by System Name.
        Specified by:
        provide in interface ProvidingManager<Route>
        Parameters:
        name - System Name f Route.
        Returns:
        new or existing Route with corresponding System Name.
        Throws:
        java.lang.IllegalArgumentException - if NamedBean doesn't already exist and the manager cannot create it due to an illegal name or name that can't be parsed.