Package org.goplanit.demands
Class Demands.TimePeriods
- java.lang.Object
-
- org.goplanit.utils.wrapper.MapWrapperImpl<Long,V>
-
- org.goplanit.utils.wrapper.LongMapWrapperImpl<TimePeriod>
-
- org.goplanit.demands.Demands.TimePeriods
-
- All Implemented Interfaces:
Cloneable
,Iterable<TimePeriod>
,LongMapWrapper<TimePeriod>
,MapWrapper<Long,TimePeriod>
- Enclosing class:
- Demands
public class Demands.TimePeriods extends LongMapWrapperImpl<TimePeriod>
Inner class to register and store time periods for the current demand object- Author:
- garym, markr
-
-
Constructor Summary
Constructors Constructor Description TimePeriods()
ConstructorTimePeriods(Demands.TimePeriods other)
Copy 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 comparablevoid
clear()
Clear all entries from mapDemands.TimePeriods
clone()
Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly createdTimePeriod
createAndRegisterNewTimePeriod(String description, long startTimeSeconds, long durationSeconds)
Factory method to create and register a new time period on the demandsTimePeriod
getByXmlId(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.-
Methods inherited from class org.goplanit.utils.wrapper.LongMapWrapperImpl
containsKey, get, remove
-
Methods inherited from class org.goplanit.utils.wrapper.MapWrapperImpl
contains, createEmptyInstance, findFirst, get, getKeyByValue, getMap, getValueToKey, isEmpty, iterator, register, remove, setMap, size, toCollection, valuesAsNewSet
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface org.goplanit.utils.wrapper.MapWrapper
addAll, contains, findFirst, forEachIn, get, getFirst, getKeyByValue, isEmpty, register, remove, size, toCollection, valuesAsNewSet
-
-
-
-
Constructor Detail
-
TimePeriods
public TimePeriods()
Constructor
-
TimePeriods
public TimePeriods(Demands.TimePeriods other)
Copy constructor- Parameters:
other
- to copy
-
-
Method Detail
-
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
-
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
-
getByXmlId
public TimePeriod getByXmlId(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
-
clone
public Demands.TimePeriods clone()
Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly created- Specified by:
clone
in interfaceMapWrapper<Long,TimePeriod>
- Specified by:
clone
in classLongMapWrapperImpl<TimePeriod>
- Returns:
- copy
-
clear
public void clear()
Clear all entries from map- Specified by:
clear
in interfaceMapWrapper<Long,TimePeriod>
- Overrides:
clear
in classMapWrapperImpl<Long,TimePeriod>
-
-