MultiState implements State { public String toJSONString() { String stateVal = this.isSuccess() ? AppInfo.getStateInfo(AppInfo.SUCCESS) : this.info; StringBuilder builder = new StringBuilder(); builder.append("{\"state\": \"").append(stateVal).append("\""); this.intMap.forEach((k, v) -> builder.append(",\"").append(k).append("\": ").append(v)); this.infoMap.forEach((k, v) -> builder.append(",\"").append(k).append("\": \"").append(v).append("\"")); builder.append(", list: [").append(String.join(",", this.stateList.toArray(new String[this.stateList.size()]))); builder.append(" ]}"); return Encoder.toUnicode(builder.toString()); } MultiState(boolean state);  MultiState(boolean state, String info);  MultiState(boolean state, int infoKey); boolean isSuccess(); void addState(State state); void putInfo(String name, String val); String toJSONString(); void putInfo(String name, long val);  }
@Test public void toJSONString(){ MultiState state=new MultiState(true); state.addState(new BaseState()); state.putInfo("test",1); state.putInfo("test","1"); System.out.println(state.toJSONString()); }