public class DependencyResolver<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DependencyResolver.NodeInfo<T>
Info object for a node.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<T> |
nodeps
The set of empty nodes.
|
protected java.util.Map<T,DependencyResolver.NodeInfo<T>> |
nodes
The nodes with dependencies.
|
Constructor and Description |
---|
DependencyResolver()
Create a new dependency resolver.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependency(T a,
T b)
Add a dependency that a depends on b.
|
void |
addNode(T node)
Add a node (without dependency).
|
void |
clear()
Clear the resolver.
|
protected DependencyResolver.NodeInfo<T> |
getNodeInfo(T node)
Get the node info for the node id.
|
java.util.Set<T> |
getNodeps()
Get the nodeps.
|
java.util.Map<T,DependencyResolver.NodeInfo<T>> |
getNodes()
Get the nodes.
|
protected boolean |
hasDependencies(T node)
Test if a node has dependencies.
|
static void |
main(java.lang.String[] args)
The main for testing.
|
void |
removeDependency(T a,
T b)
Remove a dependency that a depends on b.
|
java.util.List<T> |
resolveDependencies(boolean keep)
Resolve the DAG and deliver a valid order of nodes.
|
java.util.List<java.util.Set<T>> |
resolveDependenciesWithLevel()
Resolve the DAG and deliver a valid order of nodes with sets of nodes for same levels.
|
void |
setNodeps(java.util.Set<T> nodeps)
The nodeps to set.
|
void |
setNodes(java.util.Map<T,DependencyResolver.NodeInfo<T>> nodes)
The nodes to set.
|
protected java.util.Map<T,DependencyResolver.NodeInfo<T>> nodes
protected java.util.Set<T> nodeps
public void addDependency(T a, T b)
a
- Then source node.b
- The node the source depends on.public void removeDependency(T a, T b)
a
- Then source node.b
- The node the source depends on.public java.util.List<T> resolveDependencies(boolean keep)
public java.util.List<java.util.Set<T>> resolveDependenciesWithLevel()
public void addNode(T node)
node
- The node id.public void clear()
protected DependencyResolver.NodeInfo<T> getNodeInfo(T node)
node
- The node id.protected boolean hasDependencies(T node)
public java.util.Map<T,DependencyResolver.NodeInfo<T>> getNodes()
public void setNodes(java.util.Map<T,DependencyResolver.NodeInfo<T>> nodes)
nodes
- The nodes to setpublic java.util.Set<T> getNodeps()
public void setNodeps(java.util.Set<T> nodeps)
nodeps
- The nodeps to setpublic static void main(java.lang.String[] args)