Source:
public GenericGraph fromEntity(final GraphEntity graphEntity) { final GenericGraphBuilder genericGraphBuilder = GenericGraph.builder().namespace(graphEntity.getNamespace()); graphEntity.getProperties().forEach(property -> { final Object value = convert(property); genericGraphBuilder.property(property.getName(), value); }); graphEntity.getVertices().stream().forEach(vertexEntity -> { final GenericVertexBuilder genericVertex = GenericVertex.builder() .namespace(graphEntity.getNamespace()) .id(vertexEntity.getProperty(GenericProperties.ID).getValue()); vertexEntity.getProperties().forEach(property -> { final Object value = convert(property); genericVertex.property(property.getName(), value); }); genericGraphBuilder.addVertex(genericVertex.build()); }); graphEntity.getEdges().stream().forEach(edgeEntity -> { final GenericEdgeBuilder genericEdge = GenericEdge.builder() .namespace(edgeEntity.getNamespace()) .source(new VertexRef(edgeEntity.getSource().getNamespace(), edgeEntity.getSource().getId())) .target(new VertexRef(edgeEntity.getTarget().getNamespace(), edgeEntity.getTarget().getId())); edgeEntity.getProperties().stream() .forEach(property -> { final Object value = convert(property); genericEdge.property(property.getName(), value); }); genericGraphBuilder.addEdge(genericEdge.build()); }); final FocusEntity focusEntity = graphEntity.getDefaultFocus(); if (focusEntity == null || focusEntity.getType().equalsIgnoreCase("EMPTY")) { genericGraphBuilder.focus().empty().apply(); } else if(focusEntity.getType().equalsIgnoreCase("FIRST")) { genericGraphBuilder.focus().first().apply(); } else if(focusEntity.getType().equalsIgnoreCase("ALL")) { genericGraphBuilder.focus().all().apply(); } else if (focusEntity.getType().equalsIgnoreCase("SELECTION")) { genericGraphBuilder.focus().selection(genericGraphBuilder.getNamespace(), focusEntity.getVertexIds()).apply(); } return genericGraphBuilder.build(); }

Target:
public GenericGraph fromEntity(final GraphEntity graphEntity) { final GenericGraphBuilder genericGraphBuilder = GenericGraph.builder().namespace(graphEntity.getNamespace()); graphEntity.getProperties().forEach(property -> { final Object value = convert(property); genericGraphBuilder.property(property.getName(), value); }); graphEntity.getVertices().stream().forEach(vertexEntity -> { final GenericVertexBuilder genericVertex = GenericVertex.builder() .namespace(graphEntity.getNamespace()) .id(vertexEntity.getProperty(GenericProperties.ID).getValue()); vertexEntity.getProperties().forEach(property -> { final Object value = convert(property); genericVertex.property(property.getName(), value); }); genericGraphBuilder.addVertex(genericVertex.build()); }); graphEntity.getEdges().stream().forEach(edgeEntity -> { final GenericEdgeBuilder genericEdge = GenericEdge.builder() .namespace(edgeEntity.getNamespace()) .source(new VertexRef(edgeEntity.getSource().getNamespace(), edgeEntity.getSource().getId())) .target(new VertexRef(edgeEntity.getTarget().getNamespace(), edgeEntity.getTarget().getId())); edgeEntity.getProperties().stream() .forEach(property -> { final Object value = convert(property); genericEdge.property(property.getName(), value); }); genericGraphBuilder.addEdge(genericEdge.build()); }); final FocusEntity focusEntity = graphEntity.getDefaultFocus(); if (focusEntity == null || focusEntity.getType().equalsIgnoreCase(FocusStrategy.EMPTY)) { genericGraphBuilder.focus().empty().apply(); } else if(focusEntity.getType().equalsIgnoreCase(FocusStrategy.FIRST)) { genericGraphBuilder.focus().first().apply(); } else if(focusEntity.getType().equalsIgnoreCase(FocusStrategy.ALL)) { genericGraphBuilder.focus().all().apply(); } else if (focusEntity.getType().equalsIgnoreCase(FocusStrategy.SELECTION)) { genericGraphBuilder.focus().selection(genericGraphBuilder.getNamespace(), focusEntity.getVertexIds()).apply(); } else { throw new IllegalStateException("The focus strategy '" + focusEntity.getType() + "' read from persistence is not known."); } return genericGraphBuilder.build(); }