mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-23 20:43:53 +08:00
代码优化,由IDEA自动进行的Code Cleanup
This commit is contained in:
@@ -7,6 +7,6 @@ import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
*/
|
||||
public interface WxErrorExceptionHandler {
|
||||
|
||||
public void handle(WxErrorException e);
|
||||
void handle(WxErrorException e);
|
||||
|
||||
}
|
||||
|
@@ -22,6 +22,6 @@ public interface WxMessageDuplicateChecker {
|
||||
* @param messageId messageId需要根据上面讲的方式构造
|
||||
* @return 如果是重复消息,返回true,否则返回false
|
||||
*/
|
||||
public boolean isDuplicate(String messageId);
|
||||
boolean isDuplicate(String messageId);
|
||||
|
||||
}
|
||||
|
@@ -87,11 +87,7 @@ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChec
|
||||
}
|
||||
checkBackgroundProcessStarted();
|
||||
Long timestamp = msgId2Timestamp.putIfAbsent(messageId, System.currentTimeMillis());
|
||||
if (timestamp == null) {
|
||||
// 第一次接收到这个消息
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return timestamp != null;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -13,7 +13,7 @@ public interface InternalSession {
|
||||
*
|
||||
* @param isValid The new value for the <code>isValid</code> flag
|
||||
*/
|
||||
public void setValid(boolean isValid);
|
||||
void setValid(boolean isValid);
|
||||
|
||||
/**
|
||||
* Return the <code>isValid</code> flag for this session.
|
||||
|
@@ -28,14 +28,14 @@ public interface InternalSessionManager {
|
||||
* @exception IllegalStateException if a new session cannot be
|
||||
* instantiated for any reason
|
||||
*/
|
||||
public InternalSession createSession(String sessionId);
|
||||
InternalSession createSession(String sessionId);
|
||||
|
||||
/**
|
||||
* Remove this Session from the active Sessions for this Manager.
|
||||
*
|
||||
* @param session Session to be removed
|
||||
*/
|
||||
public void remove(InternalSession session);
|
||||
void remove(InternalSession session);
|
||||
|
||||
/**
|
||||
* Remove this Session from the active Sessions for this Manager.
|
||||
@@ -43,7 +43,7 @@ public interface InternalSessionManager {
|
||||
* @param session Session to be removed
|
||||
* @param update Should the expiration statistics be updated
|
||||
*/
|
||||
public void remove(InternalSession session, boolean update);
|
||||
void remove(InternalSession session, boolean update);
|
||||
|
||||
/**
|
||||
* Add this Session to the set of active Sessions for this Manager.
|
||||
@@ -71,7 +71,7 @@ public interface InternalSessionManager {
|
||||
/**
|
||||
* Implements the Manager interface, direct call to processExpires
|
||||
*/
|
||||
public void backgroundProcess();
|
||||
void backgroundProcess();
|
||||
|
||||
/**
|
||||
* Set the default maximum inactive interval (in seconds)
|
||||
|
@@ -323,9 +323,8 @@ public class StandardSession implements WxSession, InternalSession {
|
||||
if (!attributes.equals(session.attributes)) return false;
|
||||
if (!facade.equals(session.facade)) return false;
|
||||
if (!id.equals(session.id)) return false;
|
||||
if (!manager.equals(session.manager)) return false;
|
||||
return manager.equals(session.manager);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -4,14 +4,14 @@ import java.util.Enumeration;
|
||||
|
||||
public interface WxSession {
|
||||
|
||||
public Object getAttribute(String name);
|
||||
Object getAttribute(String name);
|
||||
|
||||
public Enumeration<String> getAttributeNames();
|
||||
Enumeration<String> getAttributeNames();
|
||||
|
||||
public void setAttribute(String name, Object value);
|
||||
void setAttribute(String name, Object value);
|
||||
|
||||
public void removeAttribute(String name);
|
||||
void removeAttribute(String name);
|
||||
|
||||
public void invalidate();
|
||||
void invalidate();
|
||||
|
||||
}
|
||||
|
@@ -5,12 +5,12 @@ public interface WxSessionManager {
|
||||
/**
|
||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。
|
||||
*/
|
||||
public WxSession getSession(String sessionId);
|
||||
WxSession getSession(String sessionId);
|
||||
|
||||
/**
|
||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。
|
||||
*/
|
||||
public WxSession getSession(String sessionId, boolean create);
|
||||
WxSession getSession(String sessionId, boolean create);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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 += '?';
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
||||
}
|
||||
|
@@ -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 += '?';
|
||||
|
@@ -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();
|
||||
|
@@ -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) {
|
||||
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user