Package org.planit.graph
Class GraphBuilderImpl
- java.lang.Object
-
- org.planit.graph.GraphBuilderImpl
-
- All Implemented Interfaces:
GraphBuilder<Vertex,Edge>
public class GraphBuilderImpl extends Object implements GraphBuilder<Vertex,Edge>
Create network entities for a physical network simulation model- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected IdGroupingToken
groupIdToken
the id group token
-
Constructor Summary
Constructors Constructor Description GraphBuilderImpl(IdGroupingToken groupIdToken)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Edge
createEdge(Vertex vertexA, Vertex vertexB, double length)
Create a new link instanceEdge
createUniqueCopyOf(Edge edgeToCopy)
create a shallo copy of the passed in edge, albeit with unique internal idsVertex
createVertex()
Create a new vertex instanceIdGroupingToken
getIdGroupingToken()
Collect the id grouping token used by this buildervoid
recreateIds(Edges<? extends Edge> edges)
recreate the ids for all passed in edgesvoid
recreateIds(Vertices<? extends Vertex> vertices)
recreate the ids for all passed in verticesvoid
setIdGroupingToken(IdGroupingToken groupIdToken)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to
-
-
-
Field Detail
-
groupIdToken
protected IdGroupingToken groupIdToken
the id group token
-
-
Constructor Detail
-
GraphBuilderImpl
public GraphBuilderImpl(IdGroupingToken groupIdToken)
Constructor- Parameters:
groupIdToken
- to use for creating element ids
-
-
Method Detail
-
createVertex
public Vertex createVertex()
Create a new vertex instance- Specified by:
createVertex
in interfaceGraphBuilder<Vertex,Edge>
- Returns:
- created vertex
-
createEdge
public Edge createEdge(Vertex vertexA, Vertex vertexB, double length) throws PlanItException
Create a new link instance- Specified by:
createEdge
in interfaceGraphBuilder<Vertex,Edge>
- Parameters:
vertexA
- the first vertex in this edgevertexB
- the second vertex in this edgelength
- the length (in km)- Returns:
- created edge
- Throws:
PlanItException
- thrown if there is an error
-
setIdGroupingToken
public void setIdGroupingToken(IdGroupingToken groupIdToken)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to- Specified by:
setIdGroupingToken
in interfaceGraphBuilder<Vertex,Edge>
- Parameters:
groupIdToken
- , contiguous id generation within this group for instances created with the factory methods
-
getIdGroupingToken
public IdGroupingToken getIdGroupingToken()
Collect the id grouping token used by this builder- Specified by:
getIdGroupingToken
in interfaceGraphBuilder<Vertex,Edge>
- Returns:
- idGroupingToken the id grouping token used by this builder
-
recreateIds
public void recreateIds(Edges<? extends Edge> edges)
recreate the ids for all passed in edges- Specified by:
recreateIds
in interfaceGraphBuilder<Vertex,Edge>
- Parameters:
edges
- to recreate ids for
-
recreateIds
public void recreateIds(Vertices<? extends Vertex> vertices)
recreate the ids for all passed in vertices- Specified by:
recreateIds
in interfaceGraphBuilder<Vertex,Edge>
- Parameters:
vertices
- to recreate ids for
-
createUniqueCopyOf
public Edge createUniqueCopyOf(Edge edgeToCopy)
create a shallo copy of the passed in edge, albeit with unique internal ids- Specified by:
createUniqueCopyOf
in interfaceGraphBuilder<Vertex,Edge>
- Parameters:
edgeToCopy
- the edge to copy- Returns:
- new edge based on passed in edge
-
-