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 protected
ManagedDirectedPathImpl(ManagedDirectedPathImpl other, boolean deepCopy)
Copy constructorprotected
ManagedDirectedPathImpl(IdGroupingToken groupId)
Constructorprotected
ManagedDirectedPathImpl(IdGroupingToken groupId, Deque<? extends EdgeSegment> pathEdgeSegments)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsSubPath(Collection<? extends EdgeSegment> subPath)
Verify if the path contains the provided subpath.boolean
containsSubPath(Iterator<? extends EdgeSegment> subPath)
Verify if the path contains the provided subpath.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.protected static long
generateId(IdGroupingToken groupId)
Generate an id for this instanceEdgeSegment
getFirstSegment()
Collect first segment on pathEdgeSegment
getLastSegment()
Collect last segment on pathIterator<EdgeSegment>
iterator()
long
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idManagedDirectedPathImpl
shallowClone()
Create a shallow copy of this entitylong
size()
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:
iterator
in interfaceIterable<EdgeSegment>
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIds
in 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:
size
in 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:
containsSubPath
in 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:
containsSubPath
in 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:
getFirstSegment
in interfaceSimpleDirectedPath
- Returns:
- initial segment
-
getLastSegment
public EdgeSegment getLastSegment()
Collect last segment on path- Specified by:
getLastSegment
in interfaceSimpleDirectedPath
- Returns:
- last segment
-
shallowClone
public ManagedDirectedPathImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceManagedDirectedPath
- Overrides:
shallowClone
in 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:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceManagedDirectedPath
- Overrides:
deepClone
in classExternalIdAbleImpl
- Returns:
- deep copy of entity
-
-