public EnumMultiMap( EnumMultiMap map ) { addAll( map ); }
public ElementMultiGraph( ElementGraph parent, EnumMultiMap annotations ) { this( parent ); getAnnotations().addAll( annotations ); }
public ElementDirectedGraph( ElementGraph parent, EnumMultiMap annotations ) { this( parent ); getAnnotations().addAll( annotations ); }
@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; }
public EnumMultiMap<FlowElement> getCaptureMap() { if( captureMap != null ) return captureMap; captureMap = new EnumMultiMap<>(); Map<FlowElement, ElementExpression> reversed = new LinkedHashMap<>(); if( Util.reverseMap( vertexMapping, reversed ) ) throw new IllegalStateException( "duplicates found in mapping" ); // returns a Set ordered topologically by the matched graph. retains this first, this second ordering for simple cases Iterator<FlowElement> iterator = ElementGraphs.getTopologicalIterator( getMatchedGraph() ); while( iterator.hasNext() ) { FlowElement next = iterator.next(); ElementExpression elementExpression = reversed.get( next ); // matchedGraph may be a super-set of what's in the mapping, so elementExpression may be null if( elementExpression == null ) continue; captureMap.addAll( elementExpression.getCapture(), next ); } return captureMap; }
protected void addParentAnnotations( ElementGraph parent ) { if( parent instanceof AnnotatedGraph && ( ( (AnnotatedGraph) parent ) ).hasAnnotations() ) getAnnotations().addAll( ( (AnnotatedGraph) parent ).getAnnotations() ); }
public EnumMultiMap<FlowElement> getAnnotations() { EnumMultiMap<FlowElement> annotations = new EnumMultiMap<>(); for( Process process : vertexSet() ) { ElementGraph elementGraph = process.getElementGraph(); if( elementGraph instanceof AnnotatedGraph ) annotations.addAll( ( (AnnotatedGraph) elementGraph ).getAnnotations() ); } return annotations; }
private ElementGraph annotateWithPriors( ElementGraph elementGraph, List<? extends ElementGraph> priorResults ) { if( priorResults == null ) return elementGraph; // the results are sub-graphs of the elementGraph, so guaranteed to exist in graph AnnotatedGraph resultGraph = new ElementMultiGraph( elementGraph ); for( ElementGraph result : priorResults ) { if( !( result instanceof AnnotatedGraph ) || !( (AnnotatedGraph) result ).hasAnnotations() ) continue; EnumMultiMap<FlowElement> annotations = ( (AnnotatedGraph) result ).getAnnotations(); resultGraph.getAnnotations().addAll( annotations ); } return (ElementGraph) resultGraph; }
@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; }
public BoundedElementMultiGraph( ElementGraph parentElementGraph, ElementGraph subElementGraph, EnumMultiMap annotations ) { graph = new DirectedMultiGraph( directed( subElementGraph ) ); addParentAnnotations( parentElementGraph ); getAnnotations().addAll( annotations ); bindHeadAndTail( parentElementGraph, subElementGraph ); }
@Override protected void addParentAnnotations( ElementGraph parentElementGraph ) { if( !( parentElementGraph instanceof AnnotatedGraph ) || !( (AnnotatedGraph) parentElementGraph ).hasAnnotations() ) return; Set<FlowElement> vertexSet = vertexSet(); EnumMultiMap parentAnnotations = ( (AnnotatedGraph) parentElementGraph ).getAnnotations(); Set<Enum> allKeys = parentAnnotations.getKeys(); for( Enum annotation : allKeys ) { Set<FlowElement> flowElements = (Set<FlowElement>) parentAnnotations.getValues( annotation ); for( FlowElement flowElement : flowElements ) { if( vertexSet.contains( flowElement ) ) getAnnotations().addAll( annotation, flowElements ); } } }
break; captureMap.addAll( current.getCaptureMap() );