diff options
Diffstat (limited to 'javanano/src/main/java/com/google')
-rw-r--r-- | javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java b/javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java index dd43cdbb..c4b2ad3d 100644 --- a/javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java +++ b/javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java @@ -35,6 +35,7 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.Map; /** * Static helper methods for printing nano protos. @@ -170,6 +171,19 @@ public final class MessageNanoPrinter { indentBuf.setLength(origIndentBufLength); buf.append(indentBuf).append(">\n"); } + } else if (object instanceof Map) { + Map<?,?> map = (Map<?,?>) object; + identifier = deCamelCaseify(identifier); + + for (Map.Entry<?,?> entry : map.entrySet()) { + buf.append(indentBuf).append(identifier).append(" <\n"); + int origIndentBufLength = indentBuf.length(); + indentBuf.append(INDENT); + print("key", entry.getKey(), indentBuf, buf); + print("value", entry.getValue(), indentBuf, buf); + indentBuf.setLength(origIndentBufLength); + buf.append(indentBuf).append(">\n"); + } } else { // Non-null primitive value identifier = deCamelCaseify(identifier); |