Package org.goplanit.demands
Class TimePeriods
- java.lang.Object
-
- org.goplanit.utils.wrapper.MapWrapperImpl<Long,V>
-
- org.goplanit.utils.wrapper.LongMapWrapperImpl<E>
-
- org.goplanit.utils.id.ManagedIdEntitiesImpl<TimePeriod>
-
- org.goplanit.demands.TimePeriods
-
- All Implemented Interfaces:
Iterable<TimePeriod>
,ManagedIdEntities<TimePeriod>
,LongMapWrapper<TimePeriod>
,MapWrapper<Long,TimePeriod>
public final class TimePeriods extends ManagedIdEntitiesImpl<TimePeriod> implements ManagedIdEntities<TimePeriod>
Class to register and store time periods for the current demand object todo: conform to managed id container- Author:
- garym, markr
-
-
Field Summary
-
Fields inherited from class org.goplanit.utils.id.ManagedIdEntitiesImpl
managedIdClass
-
-
Constructor Summary
Constructors Constructor Description TimePeriods(TimePeriods other, boolean deepCopy, BiConsumer<TimePeriod,TimePeriod> mapper)
Copy constructorTimePeriods(IdGroupingToken tokenId)
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 the time period is comparableTimePeriods
deepClone()
Deep clone implementationTimePeriods
deepCloneWithMapping(BiConsumer<TimePeriod,TimePeriod> mapper)
Deep clone implementation where the mapping for its internal copies is captured by the provided mapperTimePeriod
getByXmlId(String xmlId)
Retrieve a TimePeriod by its xml IdTimePeriodsFactory
getFactory()
Factory to create instance of managed id entity (for this container class)TimePeriods
shallowClone()
Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly created-
Methods inherited from class org.goplanit.utils.id.ManagedIdEntitiesImpl
getManagedIdClass, recreateIds, reset, updateIdMapping
-
Methods inherited from class org.goplanit.utils.wrapper.LongMapWrapperImpl
containsKey, get, remove
-
Methods inherited from class org.goplanit.utils.wrapper.MapWrapperImpl
clear, containsValue, createEmptyInstance, firstMatch, get, getKeyByValue, getMap, getValueToKey, isEmpty, iterator, register, remove, removeIf, setMap, size, toCollection, valuesAsNewSet
-
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, iterator, spliterator
-
Methods inherited from interface org.goplanit.utils.wrapper.LongMapWrapper
get, remove
-
Methods inherited from interface org.goplanit.utils.id.ManagedIdEntities
containsKey, getManagedIdClass, groupBy, recreateIds, recreateIds, reset, streamSortedBy
-
Methods inherited from interface org.goplanit.utils.wrapper.MapWrapper
addAll, clear, containsValue, firstMatch, forEachIn, get, getFirst, getKeyByValue, isEmpty, register, remove, removeAll, removeIf, size, stream, streamSorted, toCollection, toMap, valuesAsNewSet
-
-
-
-
Constructor Detail
-
TimePeriods
public TimePeriods(IdGroupingToken tokenId)
Constructor- Parameters:
tokenId
- to use for id generation
-
TimePeriods
public TimePeriods(TimePeriods other, boolean deepCopy, BiConsumer<TimePeriod,TimePeriod> mapper)
Copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwisemapper
- to apply in case of deep copy to each original to copy combination (when provided, may be null)
-
-
Method Detail
-
asSortedSetByStartTime
public SortedSet<TimePeriod> asSortedSetByStartTime()
Returns a set of all registered time periods sorted by the start time, i.e., the way the time period is comparable- Returns:
- Set of all registered time periods
-
getByXmlId
public TimePeriod getByXmlId(String xmlId)
Retrieve a TimePeriod by its xml IdThis 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
-
getFactory
public TimePeriodsFactory getFactory()
Factory to create instance of managed id entity (for this container class)- Specified by:
getFactory
in interfaceManagedIdEntities<TimePeriod>
- Returns:
- entity factory
-
shallowClone
public TimePeriods shallowClone()
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:
shallowClone
in interfaceManagedIdEntities<TimePeriod>
- Specified by:
shallowClone
in interfaceMapWrapper<Long,TimePeriod>
- Specified by:
shallowClone
in classManagedIdEntitiesImpl<TimePeriod>
- Returns:
- copy
-
deepClone
public TimePeriods deepClone()
Deep clone implementation- Specified by:
deepClone
in interfaceManagedIdEntities<TimePeriod>
- Specified by:
deepClone
in classManagedIdEntitiesImpl<TimePeriod>
- Returns:
- deep copy of entities
-
deepCloneWithMapping
public TimePeriods deepCloneWithMapping(BiConsumer<TimePeriod,TimePeriod> mapper)
Deep clone implementation where the mapping for its internal copies is captured by the provided mapper- Specified by:
deepCloneWithMapping
in interfaceManagedIdEntities<TimePeriod>
- Specified by:
deepCloneWithMapping
in classManagedIdEntitiesImpl<TimePeriod>
- Parameters:
mapper
- to apply to each mapping between original and copy- Returns:
- copy
-
-