mirror of
https://github.com/corda/corda.git
synced 2025-01-01 10:46:46 +00:00
implement Arrays.toString()
This commit is contained in:
parent
009a743aa8
commit
d1dbb45d55
@ -3,12 +3,20 @@ package java.util;
|
|||||||
public class Arrays {
|
public class Arrays {
|
||||||
private Arrays() { }
|
private Arrays() { }
|
||||||
|
|
||||||
|
public static String toString(Object[] a) {
|
||||||
|
return asList(a).toString();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean equal(Object a, Object b) {
|
private static boolean equal(Object a, Object b) {
|
||||||
return (a == null && b == null) || (a != null && a.equals(b));
|
return (a == null && b == null) || (a != null && a.equals(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> List<T> asList(final T ... array) {
|
public static <T> List<T> asList(final T ... array) {
|
||||||
return new List<T>() {
|
return new List<T>() {
|
||||||
|
public String toString() {
|
||||||
|
return Collections.toString(this);
|
||||||
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return array.length;
|
return array.length;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,19 @@ package java.util;
|
|||||||
public class Collections {
|
public class Collections {
|
||||||
private 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> {
|
static class IteratorEnumeration<T> implements Enumeration<T> {
|
||||||
private final Iterator<T> it;
|
private final Iterator<T> it;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user