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 Object
The `Node.Builder` can be used to construct a `Node` little by little.

## Constructor Summary

Constructors
Constructor
Description
`Builder()`
Constructs a new (anonymous) context-free `Node.Builder`, which can only be used to construct a single node via `buildNode()`, i.e. which cannot be chained.
`Builder(Graph.Builder.Context context)`
Constructs a new (anonymous) `Node.Builder` for the given `Graph.Builder.Context`.
`Builder(Graph.Builder.Context context, Object key)`
Constructs a new identifiable `Node.Builder` for the given `Graph.Builder.Context`.

## Method Summary

Modifier and Type
Method
Description
`Node.Builder`
`attr(String key, Object value)`
Puts the given key-value-pair into the `attributesProperty map` of the `Node` which is constructed by this `Node.Builder`.
`<T> Node.Builder`
`attr(BiConsumer<Node,T> setter, T value)`
Uses the given setter to set the attribute value.
`Graph`
`build()`
Constructs a new `Graph` from the values which have been supplied to the builder chain.
`Node`
`buildNode()`
Creates a new `Node`, setting the values specified via this `Node.Builder`.
`Edge.Builder`
`edge(Object sourceNodeOrKey, Object targetNodeOrKey)`
Constructs a new `Edge.Builder`.
`protected Object`
`getKey()`
Returns the key that can be used to identify this `Node.Builder`
`Node.Builder`
`node()`
Constructs a new (anonymous) `Node.Builder`.
`Node.Builder`
`node(Object key)`
Constructs a new (identifiable) `Node.Builder`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Builder

public Builder()
Constructs a new (anonymous) context-free `Node.Builder`, which can only be used to construct a single node via `buildNode()`, i.e. which cannot be chained.

### Builder

public Builder(Graph.Builder.Context context)
Constructs a new (anonymous) `Node.Builder` for the given `Graph.Builder.Context`.

Parameters:
  `context` - The context in which the `Node.Builder` is used.

### Builder

public Builder(Graph.Builder.Context context, Object key)
Constructs a new identifiable `Node.Builder` for the given `Graph.Builder.Context`.

Parameters:
  `context` - The context in which the `Node.Builder` is used.
  `key` - The key to identify the builder.

## Method Details

### attr

public <T> Node.Builder attr(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:
  `this` for convenience.

### attr

public Node.Builder attr(String key, Object value)
Puts the given key-value-pair into the `attributesProperty map` of the `Node` which is constructed by this `Node.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 new `Graph` from the values which have been supplied to the builder chain.

Returns:
  A new `Graph`.

### buildNode

public Node buildNode()
Creates a new `Node`, setting the values specified via this `Node.Builder`.

Returns:
  A newly created `Node`.

### edge

public Edge.Builder edge(Object sourceNodeOrKey, Object targetNodeOrKey)
Constructs a new `Edge.Builder`.

Parameters:
  `sourceNodeOrKey` - The source `Node` or a key to identify the source `Node` (or its `Node.Builder`).
  `targetNodeOrKey` - The target `Node` or a key to identify the target `Node` (or its `Node.Builder`).
Returns:
  A new `Edge.Builder`.

### getKey

protected Object getKey()
Returns the key that can be used to identify this `Node.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(Object key)
Constructs a new (identifiable) `Node.Builder`.

Parameters:
  `key` - The key that can be used to identify the `Node.Builder`
Returns:
  A new `Node.Builder`.