synchronized private String getCycle ( String objectName , String dependencyName ) { // Determine if adding this dependency will create a cycle. StringBuilder sb = new StringBuilder ( ) ; sb . append ( objectName ) ; sb . append ( " -> " ) ; sb . append ( dependencyName ) ; String nextObjectName = dependencies . get ( dependencyName ) ; while ( nextObjectName != null && ! objectName . equals ( nextObjectName ) ) { sb . append ( " -> " ) ; sb . append ( nextObjectName ) ; nextObjectName = dependencies . get ( nextObjectName ) ; } sb . append ( " -> " ) ; sb . append ( objectName ) ; return sb . toString ( ) ; }
This method creates a string describing a cycle which has been detected . It should only be called if a cycle with the specified dependency has actually been detected .