@Test void sortCandidatesTrivial() throws Exception { List<PluginDescription> descriptionList = new ArrayList<>(); assertEquals(descriptionList, PluginDependencyUtils.sortCandidates(descriptionList)); }
public static List<PluginDescription> sortCandidates(List<PluginDescription> candidates) { MutableGraph<PluginDescription> graph = GraphBuilder.directed() .allowsSelfLoops(false) .expectedNodeCount(candidates.size()) .build(); Map<String, PluginDescription> candidateMap = Maps.uniqueIndex(candidates, PluginDescription::getId); for (PluginDescription description : candidates) { graph.addNode(description); for (PluginDependency dependency : description.getDependencies()) { PluginDescription in = candidateMap.get(dependency.getId()); if (in != null) { graph.putEdge(description, in); } } } List<PluginDescription> sorted = new ArrayList<>(); Map<PluginDescription, Mark> marks = new HashMap<>(); for (PluginDescription node : graph.nodes()) { visitNode(graph, node, marks, sorted, new ArrayDeque<>()); } return sorted; }
PluginDependencyUtils { public static List<PluginDescription> sortCandidates(List<PluginDescription> candidates) { MutableGraph<PluginDescription> graph = GraphBuilder.directed() .allowsSelfLoops(false) .expectedNodeCount(candidates.size()) .build(); Map<String, PluginDescription> candidateMap = Maps.uniqueIndex(candidates, PluginDescription::getId); for (PluginDescription description : candidates) { graph.addNode(description); for (PluginDependency dependency : description.getDependencies()) { PluginDescription in = candidateMap.get(dependency.getId()); if (in != null) { graph.putEdge(description, in); } } } List<PluginDescription> sorted = new ArrayList<>(); Map<PluginDescription, Mark> marks = new HashMap<>(); for (PluginDescription node : graph.nodes()) { visitNode(graph, node, marks, sorted, new ArrayDeque<>()); } return sorted; } }
PluginDependencyUtils { public static List<PluginDescription> sortCandidates(List<PluginDescription> candidates) { MutableGraph<PluginDescription> graph = GraphBuilder.directed() .allowsSelfLoops(false) .expectedNodeCount(candidates.size()) .build(); Map<String, PluginDescription> candidateMap = Maps.uniqueIndex(candidates, PluginDescription::getId); for (PluginDescription description : candidates) { graph.addNode(description); for (PluginDependency dependency : description.getDependencies()) { PluginDescription in = candidateMap.get(dependency.getId()); if (in != null) { graph.putEdge(description, in); } } } List<PluginDescription> sorted = new ArrayList<>(); Map<PluginDescription, Mark> marks = new HashMap<>(); for (PluginDescription node : graph.nodes()) { visitNode(graph, node, marks, sorted, new ArrayDeque<>()); } return sorted; } private  PluginDependencyUtils(); }
PluginDependencyUtils { public static List<PluginDescription> sortCandidates(List<PluginDescription> candidates) { MutableGraph<PluginDescription> graph = GraphBuilder.directed() .allowsSelfLoops(false) .expectedNodeCount(candidates.size()) .build(); Map<String, PluginDescription> candidateMap = Maps.uniqueIndex(candidates, PluginDescription::getId); for (PluginDescription description : candidates) { graph.addNode(description); for (PluginDependency dependency : description.getDependencies()) { PluginDescription in = candidateMap.get(dependency.getId()); if (in != null) { graph.putEdge(description, in); } } } List<PluginDescription> sorted = new ArrayList<>(); Map<PluginDescription, Mark> marks = new HashMap<>(); for (PluginDescription node : graph.nodes()) { visitNode(graph, node, marks, sorted, new ArrayDeque<>()); } return sorted; } private  PluginDependencyUtils(); static List<PluginDescription> sortCandidates(List<PluginDescription> candidates); }
PluginDependencyUtils { public static List<PluginDescription> sortCandidates(List<PluginDescription> candidates) { MutableGraph<PluginDescription> graph = GraphBuilder.directed() .allowsSelfLoops(false) .expectedNodeCount(candidates.size()) .build(); Map<String, PluginDescription> candidateMap = Maps.uniqueIndex(candidates, PluginDescription::getId); for (PluginDescription description : candidates) { graph.addNode(description); for (PluginDependency dependency : description.getDependencies()) { PluginDescription in = candidateMap.get(dependency.getId()); if (in != null) { graph.putEdge(description, in); } } } List<PluginDescription> sorted = new ArrayList<>(); Map<PluginDescription, Mark> marks = new HashMap<>(); for (PluginDescription node : graph.nodes()) { visitNode(graph, node, marks, sorted, new ArrayDeque<>()); } return sorted; } private  PluginDependencyUtils(); static List<PluginDescription> sortCandidates(List<PluginDescription> candidates);  }