ParameterAppender { public static void appendProperty(StringBuilder builder, String name, Object value) { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException(); } if (builder.length() > 0) { final char lastChar = builder.charAt(builder.length() - 1); if (lastChar != ',' && lastChar != '{') { builder.append(','); } } appendQuotedValue(builder, name); builder.append(":"); if (value != null) { appendQuotedValue(builder, value.toString()); } else { builder.append("''"); } }  static void appendProperty(StringBuilder builder, String name, Object value);  }
@Test void testAppendProperty() { final StringBuilder builder = new StringBuilder(); ParameterAppender.appendProperty(builder, "demo1", "ding1"); assertThat(builder.toString()).isEqualTo("'demo1':'ding1'"); ParameterAppender.appendProperty(builder, "demo2", "ding2"); assertThat(builder.toString()).isEqualTo("'demo1':'ding1','demo2':'ding2'"); builder.append(",{"); ParameterAppender.appendProperty(builder, "demo3", "ding3"); builder.append("}"); assertThat(builder.toString()).isEqualTo("'demo1':'ding1','demo2':'ding2',{'demo3':'ding3'}"); }