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 IdGroupingTokengroupIdTokenthe 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 EdgecreateEdge(Vertex vertexA, Vertex vertexB, double length)Create a new link instanceEdgecreateUniqueCopyOf(Edge edgeToCopy)create a shallo copy of the passed in edge, albeit with unique internal idsVertexcreateVertex()Create a new vertex instanceIdGroupingTokengetIdGroupingToken()Collect the id grouping token used by this buildervoidrecreateIds(Edges<? extends Edge> edges)recreate the ids for all passed in edgesvoidrecreateIds(Vertices<? extends Vertex> vertices)recreate the ids for all passed in verticesvoidsetIdGroupingToken(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:
createVertexin 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:
createEdgein 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:
setIdGroupingTokenin 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:
getIdGroupingTokenin 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:
recreateIdsin 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:
recreateIdsin 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:
createUniqueCopyOfin interfaceGraphBuilder<Vertex,Edge>- Parameters:
edgeToCopy- the edge to copy- Returns:
- new edge based on passed in edge
-
-