public final class ClosureSortedDependencies<INPUT extends DependencyInfo> extends java.lang.Object implements SortedDependencies<INPUT>
Uses a stable topological sort to make sure that an input always comes after its dependencies.
Also exposes other information about the inputs, like which inputs do not provide symbols.
SortedDependencies.CircularDependencyException, SortedDependencies.MissingProvideException| Modifier and Type | Field and Description |
|---|---|
private java.util.List<INPUT> |
inputs |
private java.util.List<INPUT> |
noProvides |
private java.util.Map<java.lang.String,INPUT> |
provideMap |
private java.util.List<INPUT> |
sortedList |
| Constructor and Description |
|---|
ClosureSortedDependencies(java.util.List<INPUT> inputs) |
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
cycleToString(java.util.List<INPUT> cycle) |
private java.util.List<INPUT> |
findCycle(INPUT current,
java.util.Set<INPUT> subGraph,
com.google.common.collect.Multimap<INPUT,INPUT> deps,
java.util.Set<INPUT> covered) |
private java.util.List<INPUT> |
findCycle(java.util.List<INPUT> subGraph,
com.google.common.collect.Multimap<INPUT,INPUT> deps)
Returns the first circular dependency found.
|
private INPUT |
findRequireInSubGraphOrFail(INPUT input,
java.util.Set<INPUT> subGraph) |
java.util.List<INPUT> |
getDependenciesOf(java.util.List<INPUT> roots,
boolean sorted)
Gets all the dependencies of the given roots.
|
INPUT |
getInputProviding(java.lang.String symbol)
Return the input that gives us the given symbol.
|
java.util.List<INPUT> |
getInputsWithoutProvides() |
java.util.List<INPUT> |
getSortedDependenciesOf(java.util.List<INPUT> roots)
Gets all the dependencies of the given roots.
|
java.util.List<INPUT> |
getSortedList() |
INPUT |
maybeGetInputProviding(java.lang.String symbol)
Return the input that gives us the given symbol, or null.
|
private static <T> java.util.List<T> |
topologicalStableSort(java.util.List<T> items,
com.google.common.collect.Multimap<T,T> deps) |
private final java.util.List<INPUT extends DependencyInfo> inputs
private final java.util.List<INPUT extends DependencyInfo> sortedList
private final java.util.List<INPUT extends DependencyInfo> noProvides
private final java.util.Map<java.lang.String,INPUT extends DependencyInfo> provideMap
public ClosureSortedDependencies(java.util.List<INPUT> inputs) throws SortedDependencies.CircularDependencyException
public INPUT getInputProviding(java.lang.String symbol) throws SortedDependencies.MissingProvideException
SortedDependenciesgetInputProviding in interface SortedDependencies<INPUT extends DependencyInfo>SortedDependencies.MissingProvideException - An exception if there is no
input for this symbol.public INPUT maybeGetInputProviding(java.lang.String symbol)
SortedDependenciesmaybeGetInputProviding in interface SortedDependencies<INPUT extends DependencyInfo>private java.util.List<INPUT> findCycle(java.util.List<INPUT> subGraph, com.google.common.collect.Multimap<INPUT,INPUT> deps)
private java.util.List<INPUT> findCycle(INPUT current, java.util.Set<INPUT> subGraph, com.google.common.collect.Multimap<INPUT,INPUT> deps, java.util.Set<INPUT> covered)
private INPUT findRequireInSubGraphOrFail(INPUT input, java.util.Set<INPUT> subGraph)
private java.lang.String cycleToString(java.util.List<INPUT> cycle)
cycle - A cycle in reverse-dependency order.public java.util.List<INPUT> getSortedList()
getSortedList in interface SortedDependencies<INPUT extends DependencyInfo>public java.util.List<INPUT> getSortedDependenciesOf(java.util.List<INPUT> roots)
getSortedDependenciesOf in interface SortedDependencies<INPUT extends DependencyInfo>public java.util.List<INPUT> getDependenciesOf(java.util.List<INPUT> roots, boolean sorted)
SortedDependenciesgetDependenciesOf in interface SortedDependencies<INPUT extends DependencyInfo>sorted - If true, get them in topologically sorted order. If false,
get them in the original order they were passed to the compiler.public java.util.List<INPUT> getInputsWithoutProvides()
getInputsWithoutProvides in interface SortedDependencies<INPUT extends DependencyInfo>private static <T> java.util.List<T> topologicalStableSort(java.util.List<T> items,
com.google.common.collect.Multimap<T,T> deps)