Package org.planit.graph
Class EdgeSegmentImpl
- java.lang.Object
-
- org.planit.graph.EdgeSegmentImpl
-
- All Implemented Interfaces:
Serializable
,Comparable<Idable>
,EdgeSegment
,ExternalIdable
,Idable
- Direct Known Subclasses:
ConnectoidSegmentImpl
,LinkSegmentImpl
public class EdgeSegmentImpl extends Object implements EdgeSegment
EdgeSegment represents an edge in a particular (single) direction. Each edge has either one or two edge segments where each edge segment may have a more detailed geography than its parent link (which represents both directions via a centreline) This class is now abstract. It is extended by LinkSegment (physical links) and Connectoid (virtual links).- Author:
- markr
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EdgeSegmentImpl(EdgeSegmentImpl edgeSegmentImpl)
Copy constructorprotected
EdgeSegmentImpl(IdGroupingToken groupId, DirectedEdge parentEdge, boolean directionAB)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EdgeSegment
clone()
Clone the edge segmentboolean
equals(Object obj)
protected static long
generateEdgeSegmentId(IdGroupingToken groupId)
Generate unique edge segment idDirectedVertex
getDownstreamVertex()
Get the segment's downstream vertexString
getExternalId()
get external id of the entitylong
getId()
collect id of the entityDirectedEdge
getParentEdge()
Collect the parent edge of the segmentDirectedVertex
getUpstreamVertex()
Get the segment's upstream vertexString
getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml formatint
hashCode()
boolean
isDirectionAb()
check if edge segment runs from vertex a to b or b to aboolean
remove(DirectedVertex vertex)
Remove the vertex from the edge segment if it is either the up or downstream vertexvoid
removeParentEdge()
remove the parent edge from this edge segmentvoid
setDownstreamVertex(DirectedVertex downstreamVertex)
Set another downstream vertex.void
setExternalId(String externalId)
set the external idprotected void
setId(Long id)
set id of edge segmentvoid
setParentEdge(DirectedEdge parentEdge)
Set the parent edgevoid
setUpstreamVertex(DirectedVertex upstreamVertex)
Set another upstream vertex.void
setXmlId(String xmlId)
set the external idboolean
validate()
validate the contents of this edge segment-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.graph.EdgeSegment
replace
-
Methods inherited from interface org.planit.utils.id.ExternalIdable
hasExternalId, hasXmlId
-
Methods inherited from interface org.planit.utils.id.Idable
compareTo, idEquals, idHashCode
-
-
-
-
Field Detail
-
xmlId
protected String xmlId
Xml Id of the edge segment
-
-
Constructor Detail
-
EdgeSegmentImpl
protected EdgeSegmentImpl(IdGroupingToken groupId, DirectedEdge parentEdge, boolean directionAB) throws PlanItException
Constructor- Parameters:
groupId
- contiguous id generation within this group for instances of this classparentEdge
- parent edge of segmentdirectionAB
- direction of travel- Throws:
PlanItException
- thrown when parent edge's vertices are incompatible with directional edge segments
-
EdgeSegmentImpl
protected EdgeSegmentImpl(EdgeSegmentImpl edgeSegmentImpl)
Copy constructor- Parameters:
edgeSegmentImpl
- to copy
-
-
Method Detail
-
generateEdgeSegmentId
protected static long generateEdgeSegmentId(IdGroupingToken groupId)
Generate unique edge segment id- Parameters:
groupId
- contiguous id generation within this group for instances of this class- Returns:
- id id of this EdgeSegment
-
setId
protected void setId(Long id)
set id of edge segment- Parameters:
id
- to set
-
remove
public boolean remove(DirectedVertex vertex)
Remove the vertex from the edge segment if it is either the up or downstream vertex- Specified by:
remove
in interfaceEdgeSegment
- Parameters:
vertex
- to remove- Returns:
- true when successful, false otherwise
-
setDownstreamVertex
public void setDownstreamVertex(DirectedVertex downstreamVertex)
Set another downstream vertex.- Specified by:
setDownstreamVertex
in interfaceEdgeSegment
- Parameters:
downstreamVertex
- to use
-
setUpstreamVertex
public void setUpstreamVertex(DirectedVertex upstreamVertex)
Set another upstream vertex.- Specified by:
setUpstreamVertex
in interfaceEdgeSegment
- Parameters:
upstreamVertex
- to use
-
getUpstreamVertex
public DirectedVertex getUpstreamVertex()
Get the segment's upstream vertex- Specified by:
getUpstreamVertex
in interfaceEdgeSegment
- Returns:
- upstream vertex
-
getDownstreamVertex
public DirectedVertex getDownstreamVertex()
Get the segment's downstream vertex- Specified by:
getDownstreamVertex
in interfaceEdgeSegment
- Returns:
- downstream vertex
-
isDirectionAb
public boolean isDirectionAb()
check if edge segment runs from vertex a to b or b to a- Specified by:
isDirectionAb
in interfaceEdgeSegment
- Returns:
- true when running from a to b, otherwise false
-
getId
public long getId()
collect id of the entity
-
getParentEdge
public DirectedEdge getParentEdge()
Collect the parent edge of the segment- Specified by:
getParentEdge
in interfaceEdgeSegment
- Returns:
- parentEdge
-
setParentEdge
public void setParentEdge(DirectedEdge parentEdge)
Set the parent edge- Specified by:
setParentEdge
in interfaceEdgeSegment
- Parameters:
parentEdge
- to set
-
removeParentEdge
public void removeParentEdge()
remove the parent edge from this edge segment- Specified by:
removeParentEdge
in interfaceEdgeSegment
-
clone
public EdgeSegment clone()
Clone the edge segment- Specified by:
clone
in interfaceEdgeSegment
- Overrides:
clone
in classObject
- Returns:
- copy of this instance
-
validate
public boolean validate()
validate the contents of this edge segment- Specified by:
validate
in interfaceEdgeSegment
- Returns:
- true when valid, false otherwise
-
getExternalId
public String getExternalId()
get external id of the entity- Specified by:
getExternalId
in interfaceExternalIdable
- Returns:
- external id
-
setExternalId
public void setExternalId(String externalId)
set the external id- Specified by:
setExternalId
in interfaceExternalIdable
- Parameters:
externalId
- to set
-
getXmlId
public String getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml format- Specified by:
getXmlId
in interfaceExternalIdable
- Returns:
- xmlId
-
setXmlId
public void setXmlId(String xmlId)
set the external id- Specified by:
setXmlId
in interfaceExternalIdable
- Parameters:
xmlId
- to set
-
-