Class ModesImpl

  • All Implemented Interfaces:
    Iterable<Mode>, Modes

    public class ModesImpl
    extends Object
    implements Modes
    Implementation of the Modes interface to create and register modes on itself
    Author:
    mark
    • Constructor Detail

      • ModesImpl

        public ModesImpl​(IdGroupingToken groupId)
        Constructor
        Parameters:
        groupId - to generated id's within this group
    • Method Detail

      • register

        protected Mode register​(Mode mode)
        Add mode to the internal container
        Parameters:
        mode - to be registered in this network
        Returns:
        mode, in case it overrides an existing mode, the removed mode is returned
      • registerNewCustomMode

        public Mode registerNewCustomMode​(String name,
                                          double maxSpeed,
                                          double pcu,
                                          PhysicalModeFeatures physicalFeatures,
                                          UsabilityModeFeatures usabilityFeatures)
        Create and register new mode
        Specified by:
        registerNewCustomMode in interface Modes
        Parameters:
        name - of the mode
        maxSpeed - maximum speed of the mode
        pcu - value for the mode
        physicalFeatures - the physical features of this custom mode
        usabilityFeatures - the usability features of this custom mode
        Returns:
        new mode created
      • registerNew

        public PredefinedMode registerNew​(PredefinedModeType modeType)
                                   throws PlanItException
        Create and register a new predefined mode. When it already exists, the existing entry is returned
        Specified by:
        registerNew in interface Modes
        Parameters:
        modeType - the predefined mode type
        Returns:
        new mode created, or existing mode when already present
        Throws:
        PlanItException - thrown if error
      • size

        public int size()
        Return number of registered modes
        Specified by:
        size in interface Modes
        Returns:
        number of registered modes
      • get

        public Mode get​(long id)
        Return a Mode by its id
        Specified by:
        get in interface Modes
        Parameters:
        id - the id of the Mode
        Returns:
        the specified mode
      • containsPredefinedMode

        public boolean containsPredefinedMode​(PredefinedModeType modeType)
        verify if predefined mode is registered
        Specified by:
        containsPredefinedMode in interface Modes
        Parameters:
        modeType - to verify
        Returns:
        true when available, false otherwise
      • get

        public PredefinedMode get​(PredefinedModeType modeType)
        get predefined mode if it is registered
        Specified by:
        get in interface Modes
        Parameters:
        modeType - to collect
        Returns:
        predefined mode when available, null otherwise
      • getFirst

        public Mode getFirst()
        Collect the first registered mode
        Specified by:
        getFirst in interface Modes
        Returns:
        first registered mode if any
      • getByXmlId

        public Mode getByXmlId​(String xmlId)
        Retrieve a Mode by its xml Id This method is not efficient, since it loops through all the registered modes in order to find the required mode. The equivalent method in InputBuilderListener is more efficient and should be used in preference to this in Java code.
        Specified by:
        getByXmlId in interface Modes
        Parameters:
        xmlId - the XML Id of the specified mode
        Returns:
        the retrieved mode, or null if no mode was found
      • setOf

        public Set<Mode> setOf()
        Provide all modes as a set. This collection is a copy so any changes have no impact on the internally registered modes}
        Specified by:
        setOf in interface Modes
        Returns:
        all registered modes