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.Object
TheGraph.Builder
can be used to construct a newGraph
little by little.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Graph.Builder.Context
A 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.Builder
attr(java.lang.String key, java.lang.Object value)
Puts the given key-value-pair into theattributes map
of theGraph
which is constructed by thisGraph.Builder
.<T> Graph.Builder
attr(java.util.function.BiConsumer<Graph,T> setter, T value)
Uses the given setter to set the attribute value.Graph
build()
Constructs a newGraph
from the values which have been supplied to thisGraph.Builder
.Edge.Builder
edge(java.lang.Object sourceNodeOrKey, java.lang.Object targetNodeOrKey)
Constructs a newEdge.Builder
.Graph.Builder
edges(java.util.Collection<Edge> edges)
Graph.Builder
edges(Edge... edges)
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
.Node.Builder
node()
Constructs a new (anonymous)Node.Builder
.Node.Builder
node(java.lang.Object key)
Constructs a new (identifiable)Node.Builder
.Graph.Builder
nodes(java.util.Collection<Node> nodes)
Graph.Builder
nodes(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:
this
for convenience.
-
attr
public Graph.Builder attr(java.lang.String key, java.lang.Object value)
Puts the given key-value-pair into theattributes map
of theGraph
which is constructed by thisGraph.Builder
.- Parameters:
key
- The attribute name which is inserted.value
- The attribute value which is inserted.- Returns:
this
for convenience.
-
build
public Graph build()
Constructs a newGraph
from the values which have been supplied to thisGraph.Builder
.- Returns:
- A new
Graph
from 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 sourceNode
or a key to identify the sourceNode
(or itsNode.Builder
).targetNodeOrKey
- The targetNode
or 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
- TheEdge
s which are added to theGraph
which is constructed by thisGraph.Builder
.- Returns:
this
for convenience.
-
edges
public Graph.Builder edges(Edge... edges)
- Parameters:
edges
- TheEdge
s which are added to theGraph
which is constructed by thisGraph.Builder
.- Returns:
this
for 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 theNode
orNode.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
- TheNode
s which are added to theGraph
which is constructed by thisGraph.Builder
.- Returns:
this
for convenience.
-
nodes
public Graph.Builder nodes(Node... nodes)
- Parameters:
nodes
- TheNode
s which are added to theGraph
which is constructed by thisGraph.Builder
.- Returns:
this
for convenience.
-
-