1 package org.codehaus.plexus.util.dag;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.Iterator;
20 import java.util.List;
21
22 public class CycleDetectedException extends Exception {
23 private List<String> cycle;
24
25 public CycleDetectedException(final String message, final List<String> cycle) {
26 super(message);
27
28 this.cycle = cycle;
29 }
30
31 public List<String> getCycle() {
32 return cycle;
33 }
34
35 public String cycleToString() {
36 final StringBuilder buffer = new StringBuilder();
37
38 for (Iterator<String> iterator = cycle.iterator(); iterator.hasNext(); ) {
39 buffer.append(iterator.next());
40
41 if (iterator.hasNext()) {
42 buffer.append(" --> ");
43 }
44 }
45 return buffer.toString();
46 }
47
48 @Override
49 public String getMessage() {
50 return super.getMessage() + " " + cycleToString();
51 }
52 }