Package org.eclipse.gef.graph
Class Node.Builder
- java.lang.Object
-
- org.eclipse.gef.graph.Node.Builder
-
- Enclosing class:
- Node
public static class Node.Builder extends java.lang.ObjectTheNode.Buildercan be used to construct aNodelittle by little.
-
-
Constructor Summary
Constructors Constructor Description Builder()Constructs a new (anonymous) context-freeNode.Builder, which can only be used to construct a single node viabuildNode(), i.e. which cannot be chained.Builder(Graph.Builder.Context context)Constructs a new (anonymous)Node.Builderfor the givenGraph.Builder.Context.Builder(Graph.Builder.Context context, java.lang.Object key)Constructs a new identifiableNode.Builderfor the givenGraph.Builder.Context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Node.Builderattr(java.lang.String key, java.lang.Object value)Puts the given key-value-pair into theattributesProperty mapof theNodewhich is constructed by thisNode.Builder.<T> Node.Builderattr(java.util.function.BiConsumer<Node,T> setter, T value)Uses the given setter to set the attribute value.Graphbuild()Constructs a newGraphfrom the values which have been supplied to the builder chain.NodebuildNode()Creates a newNode, setting the values specified via thisNode.Builder.Edge.Builderedge(java.lang.Object sourceNodeOrKey, java.lang.Object targetNodeOrKey)Constructs a newEdge.Builder.protected java.lang.ObjectgetKey()Returns the key that can be used to identify thisNode.BuilderNode.Buildernode()Constructs a new (anonymous)Node.Builder.Node.Buildernode(java.lang.Object key)Constructs a new (identifiable)Node.Builder.
-
-
-
Constructor Detail
-
Builder
public Builder()
Constructs a new (anonymous) context-freeNode.Builder, which can only be used to construct a single node viabuildNode(), i.e. which cannot be chained.
-
Builder
public Builder(Graph.Builder.Context context)
Constructs a new (anonymous)Node.Builderfor the givenGraph.Builder.Context.- Parameters:
context- The context in which theNode.Builderis used.
-
Builder
public Builder(Graph.Builder.Context context, java.lang.Object key)
Constructs a new identifiableNode.Builderfor the givenGraph.Builder.Context.- Parameters:
context- The context in which theNode.Builderis used.key- The key to identify the builder.
-
-
Method Detail
-
attr
public <T> Node.Builder attr(java.util.function.BiConsumer<Node,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 Node.Builder attr(java.lang.String key, java.lang.Object value)
Puts the given key-value-pair into theattributesProperty mapof theNodewhich is constructed by thisNode.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 the builder chain.- Returns:
- A new
Graph.
-
buildNode
public Node buildNode()
Creates a newNode, setting the values specified via thisNode.Builder.- Returns:
- A newly created
Node.
-
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.
-
getKey
protected java.lang.Object getKey()
Returns the key that can be used to identify thisNode.Builder- Returns:
- The key that can be used for identification.
-
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.
-
-