private static void completePhaseDependencies(DirectAcyclicGraph dag, Object extension) { Phase.Name phase = evaluatePhase(extension); dag.add(extension, phase); for (Phase.Name name : Phase.Name.values()) { if (phase.compareTo(name) < 0) { dag.add(name, extension); } else if (phase.compareTo(name) > 0) { dag.add(extension, name); } } }
public <T> Collection<T> sort(Collection<T> extensions) { DirectAcyclicGraph dag = new DirectAcyclicGraph(); for (T extension : extensions) { dag.add(extension); for (Object dependency : getDependencies(extension)) { dag.add(extension, dependency); } for (Object generates : getDependents(extension)) { dag.add(generates, extension); } completePhaseDependencies(dag, extension); } List sortedList = dag.sort(); return Collections2.filter(sortedList, Predicates.in(extensions)); }