Package org.goplanit.service.routed
Class RoutedTripScheduleImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.service.routed.RoutedTripImpl
-
- org.goplanit.service.routed.RoutedTripScheduleImpl
-
- All Implemented Interfaces:
Comparable<IdAble>
,Iterable<RelativeLegTiming>
,ExternalIdAble
,IdAble
,ManagedId
,RoutedTrip
,RoutedTripSchedule
public class RoutedTripScheduleImpl extends RoutedTripImpl implements RoutedTripSchedule
Implementation of a RoutedTripSchedule interface.- Author:
- markr
-
-
Field Summary
-
Fields inherited from interface org.goplanit.utils.service.routed.RoutedTrip
ROUTED_TRIP_ID_CLASS
-
-
Constructor Summary
Constructors Constructor Description RoutedTripScheduleImpl(RoutedTripScheduleImpl other, boolean deepCopy)
Copy constructorRoutedTripScheduleImpl(IdGroupingToken tokenId)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelativeLegTiming
addRelativeLegSegmentTiming(ServiceLegSegment parentLegSegment, LocalTime duration, LocalTime dwellTime)
Add a new leg's timing to the end of the already registered leg timings.void
clearDepartures()
Clear all departures from the tripvoid
clearRelativeLegTimings()
Clear all leg timings from the tripRoutedTripScheduleImpl
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.LocalTime
getDefaultDwellTime()
Get defaultRoutedTripDepartures
getDepartures()
Access to the departures of this scheduleRelativeLegTiming
getRelativeLegTiming(int index)
Collect a leg timing based on its indexint
getRelativeLegTimingsSize()
Collect the number of registered leg timingsSet<ServiceNode>
getUsedServiceNodes()
Get all used service nodes along the tripIterator<RelativeLegTiming>
iterator()
Iterate over currently available relative leg timingslong
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idvoid
removeLegTiming(int legTimingIndex)
Remove the leg timing with the given index from the leg timingsvoid
resetChildManagedIdEntities()
Each class that has a managed id, should be able to reset any children that themselves are managedIdEntity containers.void
setDefaultDwellTime(LocalTime defaultDwellTime)
Set defaultRoutedTripScheduleImpl
shallowClone()
Create a shallow copy of this entityLocalTime
updateDefaultDwellTimeToMostCommon()
Update the default dwell time to the most commonly found dwell time across all rell timings and update the relative lge timings acccordingly-
Methods inherited from class org.goplanit.service.routed.RoutedTripImpl
generateId
-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, generateId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.goplanit.utils.service.routed.RoutedTrip
getIdClass
-
Methods inherited from interface org.goplanit.utils.service.routed.RoutedTripSchedule
clear, getFirstRelativeLegTiming, getLastRelativeLegTiming, getLastRelativeLegTimingIndex, getRelativeLegTimingsAsStream, hasDepartures, hasRelativeLegTimings, isValidRelativeLegTimingsIndex, removeLegTimingsIn
-
-
-
-
Constructor Detail
-
RoutedTripScheduleImpl
public RoutedTripScheduleImpl(IdGroupingToken tokenId)
Constructor- Parameters:
tokenId
- to use for id generation
-
RoutedTripScheduleImpl
public RoutedTripScheduleImpl(RoutedTripScheduleImpl other, boolean deepCopy)
Copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIds
in interfaceManagedId
- Overrides:
recreateManagedIds
in classRoutedTripImpl
- Parameters:
tokenId
- to use (may be null in case managed id entity does not rely on token to recreate its managed id(s))- Returns:
- the updated internal id
-
resetChildManagedIdEntities
public void resetChildManagedIdEntities()
Each class that has a managed id, should be able to reset any children that themselves are managedIdEntity containers. This ensures that when resetting such a container any child containers are also reset- Specified by:
resetChildManagedIdEntities
in interfaceManagedId
-
shallowClone
public RoutedTripScheduleImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceRoutedTrip
- Specified by:
shallowClone
in interfaceRoutedTripSchedule
- Specified by:
shallowClone
in classRoutedTripImpl
- Returns:
- shallow copy of entity
-
deepClone
public RoutedTripScheduleImpl deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceRoutedTrip
- Specified by:
deepClone
in interfaceRoutedTripSchedule
- Specified by:
deepClone
in classRoutedTripImpl
- Returns:
- deep copy of entity
-
getDepartures
public RoutedTripDepartures getDepartures()
Access to the departures of this schedule- Specified by:
getDepartures
in interfaceRoutedTripSchedule
- Returns:
- departures
-
clearRelativeLegTimings
public void clearRelativeLegTimings()
Clear all leg timings from the trip- Specified by:
clearRelativeLegTimings
in interfaceRoutedTripSchedule
-
clearDepartures
public void clearDepartures()
Clear all departures from the trip- Specified by:
clearDepartures
in interfaceRoutedTripSchedule
-
addRelativeLegSegmentTiming
public RelativeLegTiming addRelativeLegSegmentTiming(ServiceLegSegment parentLegSegment, LocalTime duration, LocalTime dwellTime)
Add a new leg's timing to the end of the already registered leg timings.- Specified by:
addRelativeLegSegmentTiming
in interfaceRoutedTripSchedule
- Parameters:
parentLegSegment
- (directed leg) to add to the trip's routeduration
- duration of the leg segmentdwellTime
- at the destination of the leg segment- Returns:
- the added timing
-
getRelativeLegTiming
public RelativeLegTiming getRelativeLegTiming(int index)
Collect a leg timing based on its index- Specified by:
getRelativeLegTiming
in interfaceRoutedTripSchedule
- Parameters:
index
- to collect- Returns:
- the relative leg timing found
-
getRelativeLegTimingsSize
public int getRelativeLegTimingsSize()
Collect the number of registered leg timings- Specified by:
getRelativeLegTimingsSize
in interfaceRoutedTripSchedule
- Returns:
- number of relative leg timings registered
-
removeLegTiming
public void removeLegTiming(int legTimingIndex)
Remove the leg timing with the given index from the leg timings- Specified by:
removeLegTiming
in interfaceRoutedTripSchedule
- Parameters:
legTimingIndex
- to remove
-
getDefaultDwellTime
public LocalTime getDefaultDwellTime()
Get default- Specified by:
getDefaultDwellTime
in interfaceRoutedTripSchedule
- Returns:
- default dwell time
-
updateDefaultDwellTimeToMostCommon
public LocalTime updateDefaultDwellTimeToMostCommon()
Update the default dwell time to the most commonly found dwell time across all rell timings and update the relative lge timings acccordingly- Specified by:
updateDefaultDwellTimeToMostCommon
in interfaceRoutedTripSchedule
- Returns:
- updated default dwell time
-
setDefaultDwellTime
public void setDefaultDwellTime(LocalTime defaultDwellTime)
Set default- Parameters:
defaultDwellTime
- to use
-
iterator
public Iterator<RelativeLegTiming> iterator()
Iterate over currently available relative leg timings- Specified by:
iterator
in interfaceIterable<RelativeLegTiming>
- Returns:
- iterator of relative leg timings
-
getUsedServiceNodes
public Set<ServiceNode> getUsedServiceNodes()
Get all used service nodes along the trip- Specified by:
getUsedServiceNodes
in interfaceRoutedTrip
- Returns:
- used service nodes
-
-