Refactored and reformatted code to use less static variables
This commit is contained in:
@@ -1,38 +1,37 @@
|
||||
package eu.crushedpixel.replaymod.api.client;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
public class GsonApiClient {
|
||||
|
||||
public class GsonApiClient {
|
||||
private static final JsonParser parser = new JsonParser();
|
||||
|
||||
private static final JsonParser parser = new JsonParser();
|
||||
|
||||
public static JsonElement invoke(QueryBuilder query) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invoke(query);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
public static JsonElement invoke(QueryBuilder query) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invoke(query);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
|
||||
public static JsonElement invokeJson(String url) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invokeUrl(url);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
public static JsonElement invokeJson(String url) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invokeUrl(url);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
|
||||
public static JsonElement invokeJson(String apiKey, String method, Map<String,Object> paramMap) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invoke(method, paramMap);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
public static JsonElement invokeJson(String apiKey, String method, Map<String, Object> paramMap) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invoke(method, paramMap);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
|
||||
public static JsonElement invokeJson(String apiKey, String method) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invoke(method, null);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
|
||||
private static JsonElement wrapWithJson(String apiResult) {
|
||||
JsonElement element = parser.parse(apiResult);
|
||||
return element;
|
||||
}
|
||||
public static JsonElement invokeJson(String apiKey, String method) throws IOException, ApiException {
|
||||
String apiResult = SimpleApiClient.invoke(method, null);
|
||||
return wrapWithJson(apiResult);
|
||||
}
|
||||
|
||||
private static JsonElement wrapWithJson(String apiResult) {
|
||||
JsonElement element = parser.parse(apiResult);
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user