public Set<FlowElement> getIncludedElements() { return getCapturedElements( ElementCapture.Include ); }
public Set<FlowElement> getAnchors() { return match.getCapturedElements( ElementCapture.Primary ); }
@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) { Set<FlowElement> remove = match.getCapturedElements( ElementCapture.Primary ); if( remove.isEmpty() ) return false; for( FlowElement flowElement : remove ) ElementGraphs.removeAndContract( graph, flowElement ); return true; } }
@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) { Set<FlowElement> remove = match.getCapturedElements( ElementCapture.Primary ); if( remove.isEmpty() ) return false; for( FlowElement flowElement : remove ) ElementGraphs.removeAndContract( graph, flowElement ); return true; } }
public String getMessage() { String result = message; for( ElementCapture capture : ElementCapture.values() ) { Iterator<FlowElement> iterator = match.getCapturedElements( capture ).iterator(); while( result.contains( "{" + capture + "}" ) && iterator.hasNext() ) result = result.replaceFirst( "\\{" + capture + "\\}", iterator.next().toString() ); } return result; }
@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) { Set<FlowElement> replace = match.getCapturedElements( ElementCapture.Primary ); Set<FlowElement> replaceWith = match.getCapturedElements( ElementCapture.Secondary ); if( replace.isEmpty() || replaceWith.isEmpty() ) return false; if( replace.size() != 1 ) throw new IllegalStateException( "too many captured elements" ); if( replaceWith.size() != 1 ) throw new IllegalStateException( "too many target elements" ); ElementGraphs.replaceElementWith( graph, Util.getFirst( replace ), Util.getFirst( replaceWith ) ); return true; } }
@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; } }
@Override public boolean hasNext() { if( match == null ) { match = graphFinder.findMatchesOnPrimary( plannerContext, getContractedGraph(), firstOnly, elementExcludes ); if( match.foundMatch() ) { matches.add( match ); elementExcludes.addAll( match.getCapturedElements( ElementCapture.Primary ) ); // idempotent count++; } } return match.foundMatch(); }
@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) { Set<FlowElement> captured = match.getCapturedElements( annotation.getCapture() ); if( captured.isEmpty() ) return false; ( (AnnotatedGraph) graph ).getAnnotations().addAll( annotation.getAnnotation(), captured ); return true; }
@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) { Set<FlowElement> primary = match.getCapturedElements( ElementCapture.Primary ); Set<FlowElement> secondary = match.getCapturedElements( ElementCapture.Secondary ); if( primary.isEmpty() ) return false; if( secondary.isEmpty() ) { for( FlowElement flowElement : primary ) { boolean found = ElementGraphs.removeBranchContaining( graph, flowElement ); if( !found ) throw new IllegalStateException( "no branch found at: " + flowElement ); } } else { // RemoveStreamedBranchTransformer uses a Secondary match to identify a branch but is currently unused if( secondary.size() != 1 ) throw new IllegalStateException( "too many captured secondary elements" ); boolean found = ElementGraphs.removeBranchBetween( graph, Util.getFirst( primary ), Util.getFirst( secondary ), false ); if( !found ) throw new IllegalStateException( "no branch found between: " + Util.getFirst( primary ) + " and " + Util.getFirst( secondary ) ); } return true; } }
@Override public EnumMultiMap getAnnotationMap( ElementAnnotation[] annotations ) { EnumMultiMap annotationsMap = new EnumMultiMap(); if( annotations.length == 0 ) return annotationsMap; Match match = getLastMatch(); for( ElementAnnotation annotation : annotations ) annotationsMap.addAll( annotation.getAnnotation(), match.getCapturedElements( annotation.getCapture() ) ); return annotationsMap; }
Set<FlowElement> anchoredElements = current.getCapturedElements( ElementCapture.Primary );
@Override protected boolean transformGraphInPlaceUsing( Transformed<ElementGraph> transformed, ElementGraph graph, Match match ) Set<FlowElement> insertions = match.getCapturedElements( capture );