Package org.goplanit.service.routed
Class RoutedTripFrequencyImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.service.routed.RoutedTripImpl
-
- org.goplanit.service.routed.RoutedTripFrequencyImpl
-
- All Implemented Interfaces:
Comparable<IdAble>
,Iterable<ServiceLegSegment>
,ExternalIdAble
,IdAble
,ManagedId
,RoutedTrip
,RoutedTripFrequency
public class RoutedTripFrequencyImpl extends RoutedTripImpl implements RoutedTripFrequency
Implementation of a RoutedTripFrequency interface.- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description double
frequencyPerHour
frequency of the routed trip per hourList<ServiceLegSegment>
orderedLegSegments
Ordered list of leg segments for this trip from start to end (leg segments not owned)-
Fields inherited from interface org.goplanit.utils.service.routed.RoutedTrip
ROUTED_TRIP_ID_CLASS
-
-
Constructor Summary
Constructors Constructor Description RoutedTripFrequencyImpl(RoutedTripFrequencyImpl routedTripFrequencyImpl, boolean deepCopy)
Copy constructorRoutedTripFrequencyImpl(IdGroupingToken tokenId)
Constructor
-
Method Summary
All Methods Instance Methods Concrete 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.void
clearLegs()
Clear all legs from the tripRoutedTripFrequencyImpl
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.double
getFrequencyPerHour()
Collect frequency per hour for this tripServiceLegSegment
getLegSegment(int index)
Get a leg segment in a particular position of the routed tripint
getNumberOfLegSegments()
Collect the number of registered leg segmentsSet<ServiceNode>
getUsedServiceNodes()
Get all used service nodes along the tripIterator<ServiceLegSegment>
iterator()
long
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idvoid
removeAllLegSegments()
Remove all service leg segments from the instancevoid
removeLegSegment(int index)
Remove leg segment at given index from the instancevoid
setFrequencyPerHour(double frequencyPerHour)
Set the frequency per hourRoutedTripFrequencyImpl
shallowClone()
Create a shallow copy of this entity-
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.id.ManagedId
resetChildManagedIdEntities
-
Methods inherited from interface org.goplanit.utils.service.routed.RoutedTrip
getIdClass
-
Methods inherited from interface org.goplanit.utils.service.routed.RoutedTripFrequency
clear, getFirstLegSegment, getLastLegSegment, getLastSegmentIndex, getLegSegmentsAsStream, hasLegSegments, hasPositiveFrequency, removeLegSegmentsIn
-
-
-
-
Field Detail
-
orderedLegSegments
public final List<ServiceLegSegment> orderedLegSegments
Ordered list of leg segments for this trip from start to end (leg segments not owned)
-
frequencyPerHour
public double frequencyPerHour
frequency of the routed trip per hour
-
-
Constructor Detail
-
RoutedTripFrequencyImpl
public RoutedTripFrequencyImpl(IdGroupingToken tokenId)
Constructor- Parameters:
tokenId
- to use for id generation
-
RoutedTripFrequencyImpl
public RoutedTripFrequencyImpl(RoutedTripFrequencyImpl routedTripFrequencyImpl, boolean deepCopy)
Copy constructor- Parameters:
routedTripFrequencyImpl
- 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
-
shallowClone
public RoutedTripFrequencyImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceRoutedTrip
- Specified by:
shallowClone
in interfaceRoutedTripFrequency
- Specified by:
shallowClone
in classRoutedTripImpl
- Returns:
- shallow copy of entity
-
deepClone
public RoutedTripFrequencyImpl 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 interfaceRoutedTripFrequency
- Specified by:
deepClone
in classRoutedTripImpl
- Returns:
- deep copy of entity
-
clearLegs
public void clearLegs()
Clear all legs from the trip- Specified by:
clearLegs
in interfaceRoutedTripFrequency
-
addLegSegment
public void addLegSegment(ServiceLegSegment legSegment)
Add a new leg segment (directed leg) to the end of the already registered legs.- Specified by:
addLegSegment
in interfaceRoutedTripFrequency
- Parameters:
legSegment
- to add to the trip's route
-
getFrequencyPerHour
public double getFrequencyPerHour()
Collect frequency per hour for this trip- Specified by:
getFrequencyPerHour
in interfaceRoutedTripFrequency
- Returns:
- frequencyPerHour
-
setFrequencyPerHour
public void setFrequencyPerHour(double frequencyPerHour)
Set the frequency per hour- Specified by:
setFrequencyPerHour
in interfaceRoutedTripFrequency
- Parameters:
frequencyPerHour
- to use
-
removeLegSegment
public void removeLegSegment(int index)
Remove leg segment at given index from the instance- Specified by:
removeLegSegment
in interfaceRoutedTripFrequency
- Parameters:
index
- to remove
-
removeAllLegSegments
public void removeAllLegSegments()
Remove all service leg segments from the instance- Specified by:
removeAllLegSegments
in interfaceRoutedTripFrequency
-
iterator
public Iterator<ServiceLegSegment> iterator()
- Specified by:
iterator
in interfaceIterable<ServiceLegSegment>
-
getNumberOfLegSegments
public int getNumberOfLegSegments()
Collect the number of registered leg segments- Specified by:
getNumberOfLegSegments
in interfaceRoutedTripFrequency
- Returns:
- number of registered leg segments
-
getLegSegment
public ServiceLegSegment getLegSegment(int index)
Get a leg segment in a particular position of the routed trip- Specified by:
getLegSegment
in interfaceRoutedTripFrequency
- Parameters:
index
- to collect segment for- Returns:
- the leg segment found
-
getUsedServiceNodes
public Set<ServiceNode> getUsedServiceNodes()
Get all used service nodes along the trip- Specified by:
getUsedServiceNodes
in interfaceRoutedTrip
- Returns:
- used service nodes
-
-