private boolean detectCycle(LinkedHashSet<String> dependencyAncestors, Set<String> cycles, final String child) {
    if (dependencyAncestors.contains(child)) {
      // Find index of the child in the ancestors list
      int index = -1;
      for (String s : dependencyAncestors) {
        index++;
        if (s.equals(child)) {
          break;
        }
      }
      // The cycle starts from the first time the child is seen in the ancestors list
      // and continues till the end of the list, followed by the child again.
      cycles.add(Joiner.on(" -> ").join(Iterables.skip(dependencyAncestors, index)) + " -> " + child);
      return true;
    }
    return false;
  }
private boolean detectCycle(LinkedHashSet<String> dependencyAncestors, Set<String> cycles, final String child) {
    if (dependencyAncestors.contains(child)) {
      
      int index = -1;
      for (String s : dependencyAncestors) {
        index++;
        if (s.equals(child)) {
          break;
        }
      }
      
      
      cycles.add(Joiner.on(" -> ").join(Iterables.skip(dependencyAncestors, index)) + " -> " + child);
      return true;
    }
    return false;
  }
private boolean detectCycle ( LinkedHashSet < String > dependencyAncestors , Set < String > cycles , final String child ) { if ( dependencyAncestors . contains ( child ) ) { // Find index of the child in the ancestors list int index = - 1 ; for ( String s : dependencyAncestors ) { index ++ ; if ( s . equals ( child ) ) { break ; } } // The cycle starts from the first time the child is seen in the ancestors list // and continues till the end of the list, followed by the child again. cycles . add ( Joiner . on ( " -> " ) . join ( Iterables . skip ( dependencyAncestors , index ) ) + " -> " + child ) ; return true ; } return false ; }
Returns true if child creates a dependency with any member(s) of dependencyAncestors.
Also adds the stringified cycle to the cycles list
Returns true if child creates a dependency with any member ( s ) of dependencyAncestors . Also adds the stringified cycle to the cycles list