Skip to content

Instantly share code, notes, and snippets.

@d3ep4k
Last active January 15, 2019 20:41
Show Gist options
  • Save d3ep4k/ecef31b7fdd8871226117acf80445445 to your computer and use it in GitHub Desktop.
Save d3ep4k/ecef31b7fdd8871226117acf80445445 to your computer and use it in GitHub Desktop.
class MtgOutput{
private Map<String, Object> map;
public Output(Map<String, Object> map){
this.map = map;
}
protected abstract String processJSONObject(JSONObject obj);
protected abstract String processJSONArray(JSONArray obj);
protected abstract String processString(String obj);
protected abstract String processSQLResult(ResultImpl obj);
protected abstract String singleObjectWrapper(StringBuilder builder);
protected abstract String multipleObjectWrapper(StringBuilder builder);
@Override
String toString(){
if(map.isEmpty()){
return "";
}
StringBuilder builder = new StringBuilder();
for(Map.Entry<String, Object> entry: map.entrySet()){
Object obj = entry.getValue();
if(obj instanceof JSONObject){
builder.append(processJSONObject(obj));
}
//...
}
if(map.size() > 1){
multipleObjectWrapper(builder);
}else if(map.size() == 1){
singleObjectWrapper(builder);
}
return builder.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment