@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) { ElementFactory elementFactory = transformed.getPlannerContext().getElementFactoryFor( factoryName ); if( elementFactory == null ) return false; Set<FlowElement> captured = match.getCapturedElements( ElementCapture.Primary ); if( captured.isEmpty() ) return false; else if( captured.size() != 1 ) throw new IllegalStateException( "expected one, but found multiple flow elements in the match expression: " + captured ); FlowElement replace = captured.iterator().next(); FlowElement replaceWith = elementFactory.create( graph, replace ); ElementGraphs.replaceElementWith( graph, replace, replaceWith ); return true; } }
Element element = elementFactory.create((Class<? extends Element>)field.getType(), wrappedElement);
ElementGraphs.insertFlowElementBefore( graph, flowElement, elementFactory.create( graph, flowElement ) ); break; ElementGraphs.insertFlowElementAfter( graph, flowElement, elementFactory.create( graph, flowElement ) ); break; ElementGraphs.insertFlowElementBetweenEdge( graph, incomingEdge, elementFactory.create( graph, predecessor ) ); ElementGraphs.insertFlowElementBetweenEdge( graph, outgoingEdge, elementFactory.create( graph, successor ) );