com.google.gwt.inject.rebind.resolution
Class PathFinder

java.lang.Object
  extended by com.google.gwt.inject.rebind.resolution.PathFinder

public class PathFinder
extends java.lang.Object

Finds the shortest path from the edges in the root set to any of one or more destination keys.

This is used in EagerCycleFinder and UnresolvedBindingValidator for explaining why a given error/cycle was reachable from the Ginjector.


Constructor Summary
PathFinder()
           
 
Method Summary
 PathFinder addDestinations(Key<?>... destinations)
          Add destinations to be used for the next search.
 PathFinder addRoots(Key<?>... roots)
           
 java.util.List<Dependency> findShortestPath()
          Find the shortest path from an unresolved edge in the roots to a key in the destinations.
 PathFinder onGraph(DependencyGraph graph)
           
 PathFinder withOnlyRequiredEdges(boolean onlyRequiredEdges)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathFinder

public PathFinder()
Method Detail

onGraph

public PathFinder onGraph(DependencyGraph graph)

addRoots

public PathFinder addRoots(Key<?>... roots)

addDestinations

public PathFinder addDestinations(Key<?>... destinations)
Add destinations to be used for the next search. The shortest path from the unresolved set to any member of the destination set will be returned from findShortestPath().


withOnlyRequiredEdges

public PathFinder withOnlyRequiredEdges(boolean onlyRequiredEdges)
Parameters:
onlyRequiredEdges - if true, only required edges will be considered when searching for the path

findShortestPath

public java.util.List<Dependency> findShortestPath()
Find the shortest path from an unresolved edge in the roots to a key in the destinations.

Implemented as a Breadth-first search from the destination set back to the origin.

Returns:
the shortest path from the roots to any of the destinations specified that passes through edges meeting the criteria; can be empty if destination is already in the root set, or null if no path exists