Package org.goplanit.path
Class ManagedDirectedPathImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.path.ManagedDirectedPathImpl
-
- All Implemented Interfaces:
Comparable<IdAble>,Iterable<EdgeSegment>,ExternalIdAble,IdAble,ManagedId,ManagedDirectedPath,SimpleDirectedPath
public class ManagedDirectedPathImpl extends ExternalIdAbleImpl implements ManagedDirectedPath
This object represents a path based on a number of consecutive LinkSegments The path creation makes use of the fact that the origin pair will have a null EdgeSegment, so there is no need to specify the origin.- Author:
- gman6028, markr
-
-
Field Summary
-
Fields inherited from interface org.goplanit.utils.path.ManagedDirectedPath
PATH_ID_CLASS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedManagedDirectedPathImpl(ManagedDirectedPathImpl other, boolean deepCopy)Copy constructorprotectedManagedDirectedPathImpl(IdGroupingToken groupId)ConstructorprotectedManagedDirectedPathImpl(IdGroupingToken groupId, Deque<? extends EdgeSegment> pathEdgeSegments)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsSubPath(Collection<? extends EdgeSegment> subPath)Verify if the path contains the provided subpath.booleancontainsSubPath(Iterator<? extends EdgeSegment> subPath)Verify if the path contains the provided subpath.ManagedDirectedPathImpldeepClone()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.protected static longgenerateId(IdGroupingToken groupId)Generate an id for this instanceEdgeSegmentgetFirstSegment()Collect first segment on pathEdgeSegmentgetLastSegment()Collect last segment on pathIterator<EdgeSegment>iterator()longrecreateManagedIds(IdGroupingToken tokenId)recreate the internal id(s) and set them including the Idable idManagedDirectedPathImplshallowClone()Create a shallow copy of this entitylongsize()The size of the path is given by the number of edge segments it holds-
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.path.ManagedDirectedPath
getIdClass
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
resetChildManagedIdEntities
-
Methods inherited from interface org.goplanit.utils.path.SimpleDirectedPath
computeLengthKm, hashCode, isEmpty
-
-
-
-
Constructor Detail
-
ManagedDirectedPathImpl
protected ManagedDirectedPathImpl(IdGroupingToken groupId)
Constructor- Parameters:
groupId- contiguous id generation within this group for instances of this class
-
ManagedDirectedPathImpl
protected ManagedDirectedPathImpl(IdGroupingToken groupId, Deque<? extends EdgeSegment> pathEdgeSegments)
Constructor- Parameters:
groupId- contiguous id generation within this group for instances of this classpathEdgeSegments- the path to set (not copied)
-
ManagedDirectedPathImpl
protected ManagedDirectedPathImpl(ManagedDirectedPathImpl other, boolean deepCopy)
Copy constructor- Parameters:
other- to copydeepCopy- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
generateId
protected static long generateId(IdGroupingToken groupId)
Generate an id for this instance- Parameters:
groupId- to use- Returns:
- created id
-
iterator
public Iterator<EdgeSegment> iterator()
- Specified by:
iteratorin interfaceIterable<EdgeSegment>
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIdsin interfaceManagedId- 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
-
size
public long size()
The size of the path is given by the number of edge segments it holds- Specified by:
sizein interfaceSimpleDirectedPath- Returns:
- size
-
containsSubPath
public boolean containsSubPath(Collection<? extends EdgeSegment> subPath)
Verify if the path contains the provided subpath. It is only a subpath of the subpath is present continguously- Specified by:
containsSubPathin interfaceSimpleDirectedPath- Parameters:
subPath- to verify- Returns:
- true when it contains the subpath, false otherwise.
-
containsSubPath
public boolean containsSubPath(Iterator<? extends EdgeSegment> subPath)
Verify if the path contains the provided subpath. It is only a subpath of the subpath is present contiguously- Specified by:
containsSubPathin interfaceSimpleDirectedPath- Parameters:
subPath- to verify- Returns:
- true when it contains the subpath, false otherwise.
-
getFirstSegment
public EdgeSegment getFirstSegment()
Collect first segment on path- Specified by:
getFirstSegmentin interfaceSimpleDirectedPath- Returns:
- initial segment
-
getLastSegment
public EdgeSegment getLastSegment()
Collect last segment on path- Specified by:
getLastSegmentin interfaceSimpleDirectedPath- Returns:
- last segment
-
shallowClone
public ManagedDirectedPathImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClonein interfaceIdAble- Specified by:
shallowClonein interfaceManagedDirectedPath- Overrides:
shallowClonein classExternalIdAbleImpl- Returns:
- shallow copy of entity
-
deepClone
public ManagedDirectedPathImpl 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 interfaceManagedDirectedPath- Overrides:
deepClonein classExternalIdAbleImpl- Returns:
- deep copy of entity
-
-