Package org.eclipse.gef.graph
Class Graph.Builder
- java.lang.Object
-
- org.eclipse.gef.graph.Graph.Builder
-
- Enclosing class:
- Graph
public static class Graph.Builder extends java.lang.ObjectTheGraph.Buildercan be used to construct a newGraphlittle by little.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classGraph.Builder.ContextA context object passed to nested builders when creating a builder chain.
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Graph.Builderattr(java.lang.String key, java.lang.Object value)Puts the given key-value-pair into theattributes mapof theGraphwhich is constructed by thisGraph.Builder.<T> Graph.Builderattr(java.util.function.BiConsumer<Graph,T> setter, T value)Uses the given setter to set the attribute value.Graphbuild()Constructs a newGraphfrom the values which have been supplied to thisGraph.Builder.Edge.Builderedge(java.lang.Object sourceNodeOrKey, java.lang.Object targetNodeOrKey)Constructs a newEdge.Builder.Graph.Builderedges(java.util.Collection<Edge> edges)Graph.Builderedges(Edge... edges)protected NodefindOrCreateNode(java.lang.Object key)Retrieves the node already created by a builder for the given key, or creates a new one via the respectiveNode.Builder.Node.Buildernode()Constructs a new (anonymous)Node.Builder.Node.Buildernode(java.lang.Object key)Constructs a new (identifiable)Node.Builder.Graph.Buildernodes(java.util.Collection<Node> nodes)Graph.Buildernodes(Node... nodes)
-
-
-
Method Detail
-
attr
public <T> Graph.Builder attr(java.util.function.BiConsumer<Graph,T> setter, T value)
Uses the given setter to set the attribute value.- Type Parameters:
T- The type of the attribute.- Parameters:
setter- The setter to apply.value- The value to apply.- Returns:
thisfor convenience.
-
attr
public Graph.Builder attr(java.lang.String key, java.lang.Object value)
Puts the given key-value-pair into theattributes mapof theGraphwhich is constructed by thisGraph.Builder.- Parameters:
key- The attribute name which is inserted.value- The attribute value which is inserted.- Returns:
thisfor convenience.
-
build
public Graph build()
Constructs a newGraphfrom the values which have been supplied to thisGraph.Builder.- Returns:
- A new
Graphfrom the values which have been supplied to thisGraph.Builder.
-
edge
public Edge.Builder edge(java.lang.Object sourceNodeOrKey, java.lang.Object targetNodeOrKey)
Constructs a newEdge.Builder.- Parameters:
sourceNodeOrKey- The sourceNodeor a key to identify the sourceNode(or itsNode.Builder).targetNodeOrKey- The targetNodeor a key to identify the targetNode(or itsNode.Builder).- Returns:
- A new
Edge.Builder.
-
edges
public Graph.Builder edges(java.util.Collection<Edge> edges)
- Parameters:
edges- TheEdges which are added to theGraphwhich is constructed by thisGraph.Builder.- Returns:
thisfor convenience.
-
edges
public Graph.Builder edges(Edge... edges)
- Parameters:
edges- TheEdges which are added to theGraphwhich is constructed by thisGraph.Builder.- Returns:
thisfor convenience.
-
findOrCreateNode
protected Node findOrCreateNode(java.lang.Object key)
Retrieves the node already created by a builder for the given key, or creates a new one via the respectiveNode.Builder.- Parameters:
key- The key to identify theNodeorNode.Builder.- Returns:
- An existing or newly created
Node.
-
node
public Node.Builder node()
Constructs a new (anonymous)Node.Builder.- Returns:
- A new
Node.Builder.
-
node
public Node.Builder node(java.lang.Object key)
Constructs a new (identifiable)Node.Builder.- Parameters:
key- The key that can be used to identify theNode.Builder- Returns:
- A new
Node.Builder.
-
nodes
public Graph.Builder nodes(java.util.Collection<Node> nodes)
- Parameters:
nodes- TheNodes which are added to theGraphwhich is constructed by thisGraph.Builder.- Returns:
thisfor convenience.
-
nodes
public Graph.Builder nodes(Node... nodes)
- Parameters:
nodes- TheNodes which are added to theGraphwhich is constructed by thisGraph.Builder.- Returns:
thisfor convenience.
-
-