Enhancing the APIClient
This patch adds the getListMapStrValue that returns a list of maps and a helper method to create a map from json list, it also adds a stub method for CQL queries. Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
parent
2e32584436
commit
ad23e435a1
@ -156,6 +156,17 @@ public class APIClient {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> mapStrFromJArr(JsonArray arr) {
|
||||||
|
Map<String, String> res = new HashMap<String, String>();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
JsonObject obj = arr.getJsonObject(i);
|
||||||
|
if (obj.containsKey("key") && obj.containsKey("value")) {
|
||||||
|
res.put(obj.getString("key"), obj.getString("value"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public static String join(String[] arr, String joiner) {
|
public static String join(String[] arr, String joiner) {
|
||||||
String res = "";
|
String res = "";
|
||||||
if (arr != null) {
|
if (arr != null) {
|
||||||
@ -426,4 +437,23 @@ public class APIClient {
|
|||||||
public JsonArray getJsonArray(String string) {
|
public JsonArray getJsonArray(String string) {
|
||||||
return getJsonArray(string, null);
|
return getJsonArray(string, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Map<String, String>> getListMapStrValue(String string,
|
||||||
|
MultivaluedMap<String, String> queryParams) {
|
||||||
|
JsonArray arr = getJsonArray(string, queryParams);
|
||||||
|
List<Map<String, String>> res = new ArrayList<Map<String, String>>();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
res.add(mapStrFromJArr(arr.getJsonArray(i)));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, String>> getListMapStrValue(String string) {
|
||||||
|
return getListMapStrValue(string, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabularData getCQLResult(String string) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user