@Override public boolean applies( PlannerContext plannerContext, ElementGraph elementGraph, FlowElement flowElement ) { if( elementGraph instanceof AnnotatedGraph && ( (AnnotatedGraph) elementGraph ).hasAnnotations() ) return ( (AnnotatedGraph) elementGraph ).getAnnotations().getValues( annotation ).contains( flowElement ); return false; }
@Override public Set<? extends FlowElement> getFlowElementsFor( Enum annotation ) { if( pipelineGraphs.isEmpty() ) return ( (AnnotatedGraph) getElementGraph() ).getAnnotations().getValues( annotation ); Set<FlowElement> results = createIdentitySet(); for( ElementGraph pipelineGraph : pipelineGraphs ) results.addAll( ( (AnnotatedGraph) pipelineGraph ).getAnnotations().getValues( annotation ) ); return results; }
@Override protected Set<FlowElement> addExclusions( ElementGraph graph ) { return ( (AnnotatedGraph) graph ).getAnnotations().getValues( annotation.getAnnotation() ); }
private void createPipelineMap() { if( pipelineGraphs == null || pipelineGraphs.isEmpty() ) return; Map<FlowElement, ElementGraph> map = new HashMap<>( pipelineGraphs.size() ); for( ElementGraph pipelineGraph : pipelineGraphs ) { if( !( pipelineGraph instanceof AnnotatedGraph ) ) throw new IllegalStateException( "pipeline graphs must be of type AnnotatedGraph, got: " + pipelineGraph.getClass().getName() ); Set<FlowElement> flowElements; if( ( (AnnotatedGraph) pipelineGraph ).hasAnnotations() ) flowElements = ( (AnnotatedGraph) pipelineGraph ).getAnnotations().getValues( StreamMode.Streamed ); else flowElements = ElementGraphs.findSources( pipelineGraph, FlowElement.class ); for( FlowElement flowElement : flowElements ) { if( map.containsKey( flowElement ) ) throw new IllegalStateException( "duplicate streamable elements, found: " + flowElement ); map.put( flowElement, pipelineGraph ); } } this.streamPipelineMap = map; }
private Set<FlowElement> getExclusions( List<? extends ElementGraph> elementGraphs, Enum[] annotationExcludes ) { if( elementGraphs == null ) return null; Set<FlowElement> exclusions = createIdentitySet(); for( ElementGraph elementGraph : elementGraphs ) { if( !( elementGraph instanceof AnnotatedGraph ) || !( (AnnotatedGraph) elementGraph ).hasAnnotations() ) continue; for( Enum annotationExclude : annotationExcludes ) { Set<FlowElement> flowElements = ( (AnnotatedGraph) elementGraph ).getAnnotations().getValues( annotationExclude ); if( flowElements != null ) exclusions.addAll( flowElements ); } } return exclusions; }
@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 ); } } }