Interface RoutedTripFrequency
-
- All Superinterfaces:
Comparable<IdAble>
,ExternalIdAble
,IdAble
,Iterable<ServiceLegSegment>
,ManagedId
,RoutedTrip
- All Known Implementing Classes:
RoutedTripFrequencyImpl
public interface RoutedTripFrequency extends RoutedTrip, Iterable<ServiceLegSegment>
Interface for frequency based trips of a RoutedService. The route is defined based on legs on the parent ServiceNetwork the RoutedService - and therefore the trip - resides on. Legs are ordered such that the first leg represents the starting point and the last the end point. It is expected that the legs combined are contiguous and imply the direction of the route by their ordering.- Author:
- markr
-
-
Field Summary
-
Fields inherited from interface org.goplanit.utils.service.routed.RoutedTrip
ROUTED_TRIP_ID_CLASS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addLegSegment(ServiceLegSegment legSegment)
Add a new leg segment (directed leg) to the end of the already registered legs.default void
clear()
Clear the instance by setting frequency to 0 and removing all service leg segmentsvoid
clearLegs()
Clear all legs from the tripRoutedTripFrequency
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.default ServiceLegSegment
getFirstLegSegment()
Get first leg segment of the routed tripdouble
getFrequencyPerHour()
Collect frequency per hour for this tripdefault ServiceLegSegment
getLastLegSegment()
Get last leg segment of the routed tripdefault int
getLastSegmentIndex()
Provide the last valid leg segment indexServiceLegSegment
getLegSegment(int index)
Get a leg segment in a particular position of the routed tripdefault Stream<ServiceLegSegment>
getLegSegmentsAsStream()
convert this iterable into a stream and provide its leg segments this wayint
getNumberOfLegSegments()
Collect the number of registered leg segmentsdefault boolean
hasLegSegments()
Verify if there are leg segments registereddefault boolean
hasPositiveFrequency()
Verify if a valid frequency is defined, must be positive to be validvoid
removeAllLegSegments()
Remove all service leg segments from the instancevoid
removeLegSegment(int index)
Remove leg segment at given index from the instancedefault void
removeLegSegmentsIn(List<Integer> segmentIndicesToRemove)
Remove the segments in ascending order by their index.void
setFrequencyPerHour(double frequencyPerHour)
Set the frequency per hourRoutedTripFrequency
shallowClone()
Create a shallow copy of this entity-
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, iterator, spliterator
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
recreateManagedIds, resetChildManagedIdEntities
-
Methods inherited from interface org.goplanit.utils.service.routed.RoutedTrip
getIdClass, getUsedServiceNodes
-
-
-
-
Method Detail
-
clearLegs
void clearLegs()
Clear all legs from the trip
-
getNumberOfLegSegments
int getNumberOfLegSegments()
Collect the number of registered leg segments- Returns:
- number of registered leg segments
-
addLegSegment
void addLegSegment(ServiceLegSegment legSegment)
Add a new leg segment (directed leg) to the end of the already registered legs.- Parameters:
legSegment
- to add to the trip's route
-
getLegSegment
ServiceLegSegment getLegSegment(int index)
Get a leg segment in a particular position of the routed trip- Parameters:
index
- to collect segment for- Returns:
- the leg segment found
-
getFrequencyPerHour
double getFrequencyPerHour()
Collect frequency per hour for this trip- Returns:
- frequencyPerHour
-
setFrequencyPerHour
void setFrequencyPerHour(double frequencyPerHour)
Set the frequency per hour- Parameters:
frequencyPerHour
- to use
-
hasPositiveFrequency
default boolean hasPositiveFrequency()
Verify if a valid frequency is defined, must be positive to be valid- Returns:
- true when a positive frequency is defined, false otherwise
-
hasLegSegments
default boolean hasLegSegments()
Verify if there are leg segments registered- Returns:
- true when leg segments are registered, false otherwise
-
getFirstLegSegment
default ServiceLegSegment getFirstLegSegment()
Get first leg segment of the routed trip- Returns:
- the leg segment with id 0
-
getLastLegSegment
default ServiceLegSegment getLastLegSegment()
Get last leg segment of the routed trip- Returns:
- the last segment, i.e., the one with the highest id
-
removeLegSegment
void removeLegSegment(int index)
Remove leg segment at given index from the instance- Parameters:
index
- to remove
-
removeAllLegSegments
void removeAllLegSegments()
Remove all service leg segments from the instance
-
shallowClone
RoutedTripFrequency shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceRoutedTrip
- Returns:
- shallow copy of entity
-
deepClone
RoutedTripFrequency 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
- Returns:
- deep copy of entity
-
clear
default void clear()
Clear the instance by setting frequency to 0 and removing all service leg segments
-
removeLegSegmentsIn
default void removeLegSegmentsIn(List<Integer> segmentIndicesToRemove)
Remove the segments in ascending order by their index. Note that after removal indices might have shifted due to removal of entries- Parameters:
segmentIndicesToRemove
- to remove, should be in ascending order
-
getLastSegmentIndex
default int getLastSegmentIndex()
Provide the last valid leg segment index- Returns:
- last index, e.g., size - 1
-
getLegSegmentsAsStream
default Stream<ServiceLegSegment> getLegSegmentsAsStream()
convert this iterable into a stream and provide its leg segments this way- Returns:
- service leg segments as stream
-
-