代码优化,由IDEA自动进行的Code Cleanup

This commit is contained in:
BinaryWang
2016-07-27 17:57:13 +08:00
parent 38ab7759cb
commit b1f0b0787a
44 changed files with 140 additions and 156 deletions

View File

@@ -14,7 +14,7 @@ public class InputStreamResponseHandler implements ResponseHandler<InputStream>
public static final ResponseHandler<InputStream> INSTANCE = new InputStreamResponseHandler();
public InputStream handleResponse(final HttpResponse response) throws HttpResponseException, IOException {
public InputStream handleResponse(final HttpResponse response) throws IOException {
final StatusLine statusLine = response.getStatusLine();
final HttpEntity entity = response.getEntity();
if (statusLine.getStatusCode() >= 300) {

View File

@@ -39,7 +39,7 @@ public class MediaDownloadRequestExecutor implements RequestExecutor<File, Strin
@Override
public File execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, ClientProtocolException, IOException {
public File execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';

View File

@@ -25,7 +25,7 @@ import java.io.IOException;
public class MediaUploadRequestExecutor implements RequestExecutor<WxMediaUploadResult, File> {
@Override
public WxMediaUploadResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, File file) throws WxErrorException, ClientProtocolException, IOException {
public WxMediaUploadResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, File file) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

View File

@@ -26,6 +26,6 @@ public interface RequestExecutor<T, E> {
* @throws ClientProtocolException
* @throws IOException
*/
public T execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, E data) throws WxErrorException, ClientProtocolException, IOException;
T execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, E data) throws WxErrorException, IOException;
}

View File

@@ -19,7 +19,7 @@ import java.io.IOException;
public class SimpleGetRequestExecutor implements RequestExecutor<String, String> {
@Override
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, ClientProtocolException, IOException {
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException {
if (queryParam != null) {
if (uri.indexOf('?') == -1) {
uri += '?';

View File

@@ -21,7 +21,7 @@ import java.io.IOException;
public class SimplePostRequestExecutor implements RequestExecutor<String, String> {
@Override
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String postEntity) throws WxErrorException, ClientProtocolException, IOException {
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String postEntity) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

View File

@@ -19,7 +19,7 @@ public class Utf8ResponseHandler implements ResponseHandler<String> {
public static final ResponseHandler<String> INSTANCE = new Utf8ResponseHandler();
public String handleResponse(final HttpResponse response) throws HttpResponseException, IOException {
public String handleResponse(final HttpResponse response) throws IOException {
final StatusLine statusLine = response.getStatusLine();
final HttpEntity entity = response.getEntity();
if (statusLine.getStatusCode() >= 300) {

View File

@@ -91,7 +91,7 @@ public class GsonHelper {
public static boolean getAsPrimitiveBool(JsonElement element) {
Boolean r = getAsBoolean(element);
return r == null ? false : r.booleanValue();
return r != null && r.booleanValue();
}
public static Double getAsDouble(JsonElement element) {

View File

@@ -211,10 +211,7 @@ public class StringManager {
@Override
protected boolean removeEldestEntry(
Map.Entry<Locale,StringManager> eldest) {
if (size() > (LOCALE_CACHE_SIZE - 1)) {
return true;
}
return false;
return size() > (LOCALE_CACHE_SIZE - 1);
}
};
managers.put(packageName, map);