Add a new library template to Java client: okhttp-gson

which uses OkHttp as HTTP library and Gson as JSON processing library
This commit is contained in:
xhh
2015-08-31 18:42:09 +08:00
parent 8114c416b9
commit 3c84847adb
13 changed files with 1311 additions and 13 deletions

View File

@@ -6,20 +6,45 @@ import java.util.List;
{{>generatedAnnotation}}
public class ApiException extends Exception {
private int code = 0;
private String message = null;
private Map<String, List<String>> responseHeaders = null;
private String responseBody = null;
public ApiException() {}
public ApiException(int code, String message) {
public ApiException(Throwable throwable) {
super(throwable);
}
public ApiException(String message) {
super(message);
}
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
super(message, throwable);
this.code = code;
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
}
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
this(message, (Throwable) null, code, responseHeaders, responseBody);
}
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
this(message, throwable, code, responseHeaders, null);
}
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
this((String) null, (Throwable) null, code, responseHeaders, responseBody);
}
public ApiException(int code, String message) {
super(message);
this.code = code;
this.message = message;
}
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
this.code = code;
this.message = message;
this(code, message);
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
}
@@ -28,10 +53,6 @@ public class ApiException extends Exception {
return code;
}
public String getMessage() {
return message;
}
/**
* Get the HTTP response headers.
*/