Last active
January 15, 2019 20:41
-
-
Save d3ep4k/ecef31b7fdd8871226117acf80445445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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