private final WaitRecommendations getRecommendationsFor(List<Path> paths) { WaitRecommendations result = null; for (Path path : paths) { if (result == null) { String lastExpression = path.getLastExpression(); result = new WaitRecommendations(lastExpression); } String waitForExpression = path.getSecondLastExpression(); result.addRecommendation(waitForExpression); } return result; }
private final void storeRecommendationsFromPath(Path prefix, List<Path> consideredPaths) { String lastCommonExpression = prefix.getLastExpression(); WaitRecommendations waitRecommendations = getRecommendationsFor(consideredPaths); Set<String> recommendationsSet = waitRecommendations.getRecommendations(); for (String expressionToWaitFor : recommendationsSet) { WaitRecommendations recommendationsToStore = waitRecommendations.dup(); recommendationsToStore.removeExpressionToWaitFor(expressionToWaitFor); Map<String, Set<WaitRecommendations>> innerMap = recommendations.get(expressionToWaitFor); if (innerMap == null) { innerMap = new HashMap<String, Set<WaitRecommendations>>(); recommendations.put(expressionToWaitFor, innerMap); } Set<WaitRecommendations> waitSet = innerMap.get(lastCommonExpression); if (waitSet == null) { waitSet = new HashSet<WaitRecommendations>(); innerMap.put(lastCommonExpression, waitSet); } waitSet.add(recommendationsToStore); } }