Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 480293

Summary: Improve GEF4 Graph Builder API
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF GraphAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.2.0   
Target Milestone: 4.0.0 / 3.11.0 (Neon) M3   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nyßen CLA 2015-10-21 08:00:46 EDT
The current builder API provided by GEF4 Graph does not seem to be really suited to build up graphs. It should be possible to build nodes and edges directly "inline" a graph builder. It should also be possible to make builders identifiable (with a key), so e.g. node builders can be reused when linking edges.
Comment 1 Alexander Nyßen CLA 2015-10-22 04:32:47 EDT
Pushed the following changes to origin/master:

- Ensured that builders can be properly chained (introduced context).
- Ensured edge builder can refer to node (builders) via Object keys.
- Changed that Node.Builder#build() and Edge.Builder#build() now build the Graph (for the entire chain). Introduced buildNode() and buildEdge() for the former use cases.

This way, the builder API can now be used as follows:

Graph g1 = new Graph.Builder()
  .attr(DotProperties.GRAPH_TYPE, DotProperties.GRAPH_TYPE_UNDIRECTED)//
  .node("n1")//
    .attr(DotProperties.NODE_LABEL, "1")//
    .attr(DotProperties.NODE_ID, "1")//
  .node("n2")//
    .attr(DotProperties.NODE_LABEL, "2")//
    .attr(DotProperties.NODE_ID, "2")//
  .node("n3")//
    .attr(DotProperties.NODE_LABEL, "3")//
    .attr(DotProperties.NODE_ID, "3")//
  .edge("n1", "n2")//
  .edge("n1", "n3")//
.build();

As node (builders) can be referred to by (Object) keys, this allows to construct nodes and edges in a single builder chain.

Resolving as fixed in 3.11.0 M3.