Class Demands.TimePeriods

  • All Implemented Interfaces:
    Iterable<TimePeriod>
    Enclosing class:
    Demands

    public class Demands.TimePeriods
    extends Object
    implements Iterable<TimePeriod>
    Inner class to register and store time periods for the current demand object
    Author:
    garym
    • Constructor Detail

      • TimePeriods

        public TimePeriods()
        Constructor
    • Method Detail

      • registerTimePeriod

        protected void registerTimePeriod​(TimePeriod timePeriod)
        Register a time period
        Parameters:
        timePeriod - time period to be registered
      • createAndRegisterNewTimePeriod

        public TimePeriod createAndRegisterNewTimePeriod​(String description,
                                                         long startTimeSeconds,
                                                         long durationSeconds)
                                                  throws PlanItException
        Factory method to create and register a new time period on the demands
        Parameters:
        description - the description for this time period
        startTimeSeconds - the start time in seconds since midnight (00:00)
        durationSeconds - the duration in seconds since start time
        Returns:
        new time period created
        Throws:
        PlanItException - thrown if start time and/or duration are invalid
      • getTimePeriodById

        public TimePeriod getTimePeriodById​(long id)
        Retrieve a time period by its id
        Parameters:
        id - id of the time period
        Returns:
        retrieved time period
      • getNumberOfTimePeriods

        public int getNumberOfTimePeriods()
        Collect the number of registered time periods
        Returns:
        numver of time periods
      • getFirst

        public TimePeriod getFirst()
        Collect the first registered time period. This is not necessarily the earliest time period.
        Returns:
        first registered time period
      • asSortedSetByStartTime

        public SortedSet<TimePeriod> asSortedSetByStartTime()
        Returns a set of all registered time periods sorted by the start time, i.e., the way th time period is comparable
        Returns:
        Set of all registered time periods
      • getTimePeriodByXmlId

        public TimePeriod getTimePeriodByXmlId​(String xmlId)
        Retrieve a TimePeriod by its xml Id This method is not efficient, since it loops through all the registered time periods in order to find the required time period.
        Parameters:
        xmlId - the XML Id of the specified time period
        Returns:
        the retrieved time period, or null if no time period was found