Github user kishorvpatil commented on a diff in the pull request:
https://github.com/apache/storm/pull/2882#discussion_r227061504
--- Diff: storm-core/src/jvm/org/apache/storm/command/AdminCommands.java ---
@@ -104,6 +115,164 @@ public void printCliHelp(String command, PrintStream
out) {
}
}
+ /**
+ * Print value in a human readable format.
+ * @param value what to print.
+ * @return a human readable string
+ */
+ public static String prettyPrint(TBase value) {
+ StringBuilder builder = new StringBuilder();
+ prettyPrint(value, 0, builder);
+ return builder.toString();
+ }
+
+ private static void println(StringBuilder out, int depth, Object
value) {
+ for (int i = 0; i < depth; i++) {
+ out.append("\t");
+ }
+ out.append(value);
+ out.append("\n");
+ }
+
+ private static void prettyPrint(TBase value, int depth, StringBuilder
out) {
+ if (value == null) {
+ println(out, depth,"null");
+ return;
+ }
+ println(out, depth, "{");
+ prettyPrintFields(value, depth + 1, out);
+ println(out, depth, "}");
+ }
+
+ private static void prettyPrintFields(TBase value, int depth,
StringBuilder out) {
+ for (Map.Entry<? extends TFieldIdEnum, FieldMetaData> entry :
FieldMetaData.getStructMetaDataMap(value.getClass()).entrySet()) {
+ TFieldIdEnum key = entry.getKey();
+ if (!value.isSet(key)) {
+ println(out, depth, key.getFieldName() + ": not set");
--- End diff --
Simply make this empty "" String result or `{}`. not set is not exactly
parsable json
---