public static Collection < CommunicationSummaryStatistics > buildCommunicationSummaryTree ( Collection < CommunicationSummaryStatistics > nodes , Set < String > endpoints ) { Map < String , CommunicationSummaryStatistics > nodeMap = new HashMap < String , CommunicationSummaryStatistics > ( ) ; // Create a map of nodes for ( CommunicationSummaryStatistics css : nodes ) { nodeMap . put ( css . getId ( ) , css ) ; } List < CommunicationSummaryStatistics > ret = new ArrayList <> ( ) ; for ( String endpoint : endpoints ) { // Check if a 'client' node also exists for the endpoint, and if so, use this as the // initial endpoint CommunicationSummaryStatistics n = nodeMap . get ( EndpointUtil . encodeClientURI ( endpoint ) ) ; if ( n == null ) { n = nodeMap . get ( endpoint ) ; } if ( n != null ) { CommunicationSummaryStatistics rootNode = new CommunicationSummaryStatistics ( n ) ; initCommunicationSummaryTreeNode ( rootNode , nodeMap , new HashSet <> ( Collections . singleton ( rootNode . getId ( ) ) ) ) ; ret . add ( rootNode ) ; } } return ret ; }
This method returns the supplied list of flat nodes as a set of tree structures with related nodes .