01: /**
02: *
03: */package org.junit.experimental.theories.internal;
04:
05: import java.util.Arrays;
06: import java.util.Collection;
07: import java.util.Iterator;
08:
09: public class ParameterizedAssertionError extends RuntimeException {
10: private static final long serialVersionUID = 1L;
11:
12: public ParameterizedAssertionError(Throwable targetException,
13: String methodName, Object... params) {
14: super (String.format("%s(%s)", methodName, join(", ", params)),
15: targetException);
16: }
17:
18: @Override
19: public boolean equals(Object obj) {
20: return toString().equals(obj.toString());
21: }
22:
23: public static String join(String delimiter, Object... params) {
24: return join(delimiter, Arrays.asList(params));
25: }
26:
27: public static String join(String delimiter,
28: Collection<Object> values) {
29: StringBuffer buffer = new StringBuffer();
30: Iterator<Object> iter = values.iterator();
31: while (iter.hasNext()) {
32: Object next = iter.next();
33: buffer.append(String.valueOf(next));
34: if (iter.hasNext()) {
35: buffer.append(delimiter);
36: }
37: }
38: return buffer.toString();
39: }
40: }
|