Convenience method for Map instances

This commit is contained in:
Mumfrey committed 2016-02-17 18:50:49 +00:00
1 parent 8e891daa92
commit 6978f25855
1 file changed
+16 -1
@@ -27,6 +27,7 @@ package org.spongepowered.asm.util;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -232,7 +233,7 @@ public class PrettyPrinter {
}
return this;
}
public PrettyPrinter addWrapped(String format, Object... args) {
return this.addWrapped(this.wrapWidth, format, args);
}
@@ -324,6 +325,20 @@ public class PrettyPrinter {
return this;
}
/**
* Add all values of the specified map to this printer as key/value pairs
*
* @param map Map with entries to add
* @return fluent
*/
public PrettyPrinter add(Map<?, ?> map) {
for (Map.Entry<?, ?> entry : map.entrySet()) {
String key = entry.getKey() == null ? "null" : entry.getKey().toString();
this.kv(key, entry.getValue());
}
return this;
}
/**
* Adds a horizontal rule to the output
*