Package org.planit.demands
Class Demands.TimePeriods
- java.lang.Object
-
- org.planit.demands.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 Summary
Constructors Constructor Description TimePeriods()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SortedSet<TimePeriod>
asSortedSetByStartTime()
Returns a set of all registered time periods sorted by the start time, i.e., the way th time period is comparableTimePeriod
createAndRegisterNewTimePeriod(String description, long startTimeSeconds, long durationSeconds)
Factory method to create and register a new time period on the demandsTimePeriod
getFirst()
Collect the first registered time period.int
getNumberOfTimePeriods()
Collect the number of registered time periodsTimePeriod
getTimePeriodById(long id)
Retrieve a time period by its idTimePeriod
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.Iterator<TimePeriod>
iterator()
Iterator for time periods (non-sorted)protected void
registerTimePeriod(TimePeriod timePeriod)
Register a time period-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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 periodstartTimeSeconds
- 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
-
iterator
public Iterator<TimePeriod> iterator()
Iterator for time periods (non-sorted)- Specified by:
iterator
in interfaceIterable<TimePeriod>
- Returns:
- iterator
-
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
-
-