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 RelativeLegTimingaddRelativeLegSegmentTiming(ServiceLegSegment parentLegSegment, LocalTime duration, LocalTime dwellTime)Add a new leg's timing to the end of the already registered leg timings.voidclearDepartures()Clear all departures from the tripvoidclearRelativeLegTimings()Clear all leg timings from the tripRoutedTripScheduleImpldeepClone()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.LocalTimegetDefaultDwellTime()Get defaultRoutedTripDeparturesgetDepartures()Access to the departures of this scheduleRelativeLegTiminggetRelativeLegTiming(int index)Collect a leg timing based on its indexintgetRelativeLegTimingsSize()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 timingslongrecreateManagedIds(IdGroupingToken tokenId)recreate the internal id(s) and set them including the Idable idvoidremoveLegTiming(int legTimingIndex)Remove the leg timing with the given index from the leg timingsvoidresetChildManagedIdEntities()Each class that has a managed id, should be able to reset any children that themselves are managedIdEntity containers.voidsetDefaultDwellTime(LocalTime defaultDwellTime)Set defaultRoutedTripScheduleImplshallowClone()Create a shallow copy of this entityLocalTimeupdateDefaultDwellTimeToMostCommon()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:
recreateManagedIdsin interfaceManagedId- Overrides:
recreateManagedIdsin 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:
resetChildManagedIdEntitiesin interfaceManagedId
-
shallowClone
public RoutedTripScheduleImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClonein interfaceIdAble- Specified by:
shallowClonein interfaceRoutedTrip- Specified by:
shallowClonein interfaceRoutedTripSchedule- Specified by:
shallowClonein 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:
deepClonein interfaceIdAble- Specified by:
deepClonein interfaceRoutedTrip- Specified by:
deepClonein interfaceRoutedTripSchedule- Specified by:
deepClonein classRoutedTripImpl- Returns:
- deep copy of entity
-
getDepartures
public RoutedTripDepartures getDepartures()
Access to the departures of this schedule- Specified by:
getDeparturesin interfaceRoutedTripSchedule- Returns:
- departures
-
clearRelativeLegTimings
public void clearRelativeLegTimings()
Clear all leg timings from the trip- Specified by:
clearRelativeLegTimingsin interfaceRoutedTripSchedule
-
clearDepartures
public void clearDepartures()
Clear all departures from the trip- Specified by:
clearDeparturesin 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:
addRelativeLegSegmentTimingin 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:
getRelativeLegTimingin interfaceRoutedTripSchedule- Parameters:
index- to collect- Returns:
- the relative leg timing found
-
getRelativeLegTimingsSize
public int getRelativeLegTimingsSize()
Collect the number of registered leg timings- Specified by:
getRelativeLegTimingsSizein 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:
removeLegTimingin interfaceRoutedTripSchedule- Parameters:
legTimingIndex- to remove
-
getDefaultDwellTime
public LocalTime getDefaultDwellTime()
Get default- Specified by:
getDefaultDwellTimein 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:
updateDefaultDwellTimeToMostCommonin 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:
iteratorin interfaceIterable<RelativeLegTiming>- Returns:
- iterator of relative leg timings
-
getUsedServiceNodes
public Set<ServiceNode> getUsedServiceNodes()
Get all used service nodes along the trip- Specified by:
getUsedServiceNodesin interfaceRoutedTrip- Returns:
- used service nodes
-
-