Add toString method in AbstractMultiValuedMap#KeysMultiSet.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1714708 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2015-11-16 23:09:01 +00:00
parent 8ed80d9d68
commit ccda2db161
1 changed files with 22 additions and 0 deletions

View File

@ -716,6 +716,28 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K,
};
}
@Override
public String toString() {
if (size() == 0) {
return "[]";
}
final StringBuilder buf = new StringBuilder();
buf.append('[');
final Iterator<K> it = KeysMultiSet.this.uniqueSet().iterator();
while (it.hasNext()) {
final Object current = it.next();
final int count = getCount(current);
buf.append(current);
buf.append(':');
buf.append(count);
if (it.hasNext()) {
buf.append(", ");
}
}
buf.append(']');
return buf.toString();
}
}
/**