mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
implement Arrays.toString()
This commit is contained in:
parent
009a743aa8
commit
d1dbb45d55
@ -3,12 +3,20 @@ package java.util;
|
||||
public class Arrays {
|
||||
private Arrays() { }
|
||||
|
||||
public static String toString(Object[] a) {
|
||||
return asList(a).toString();
|
||||
}
|
||||
|
||||
private static boolean equal(Object a, Object b) {
|
||||
return (a == null && b == null) || (a != null && a.equals(b));
|
||||
}
|
||||
|
||||
public static <T> List<T> asList(final T ... array) {
|
||||
return new List<T>() {
|
||||
public String toString() {
|
||||
return Collections.toString(this);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return array.length;
|
||||
}
|
||||
|
@ -3,6 +3,19 @@ package java.util;
|
||||
public class Collections {
|
||||
private Collections() { }
|
||||
|
||||
static String toString(List l) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[");
|
||||
for (Iterator it = l.iterator(); it.hasNext();) {
|
||||
sb.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static class IteratorEnumeration<T> implements Enumeration<T> {
|
||||
private final Iterator<T> it;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user