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

This commit is contained in:
BinaryWang
2016-07-27 17:57:13 +08:00
parent 622e185203
commit 3d6778f83a
44 changed files with 140 additions and 156 deletions

View File

@@ -13,89 +13,89 @@ import java.io.File;
*/
public interface WxMpConfigStorage {
public String getAccessToken();
String getAccessToken();
public boolean isAccessTokenExpired();
boolean isAccessTokenExpired();
/**
* 强制将access token过期掉
*/
public void expireAccessToken();
void expireAccessToken();
/**
* 应该是线程安全的
* @param accessToken
*/
public void updateAccessToken(WxAccessToken accessToken);
void updateAccessToken(WxAccessToken accessToken);
/**
* 应该是线程安全的
* @param accessToken
* @param expiresIn
*/
public void updateAccessToken(String accessToken, int expiresIn);
void updateAccessToken(String accessToken, int expiresIn);
public String getJsapiTicket();
String getJsapiTicket();
public boolean isJsapiTicketExpired();
boolean isJsapiTicketExpired();
/**
* 强制将jsapi ticket过期掉
*/
public void expireJsapiTicket();
void expireJsapiTicket();
/**
* 应该是线程安全的
* @param jsapiTicket
*/
public void updateJsapiTicket(String jsapiTicket, int expiresInSeconds);
void updateJsapiTicket(String jsapiTicket, int expiresInSeconds);
public String getCardApiTicket();
String getCardApiTicket();
public boolean isCardApiTicketExpired();
boolean isCardApiTicketExpired();
/**
* 强制将卡券api ticket过期掉
*/
public void expireCardApiTicket();
void expireCardApiTicket();
/**
* 应该是线程安全的
* @param cardApiTicket
*/
public void updateCardApiTicket(String cardApiTicket, int expiresInSeconds);
void updateCardApiTicket(String cardApiTicket, int expiresInSeconds);
public String getAppId();
String getAppId();
public String getSecret();
String getSecret();
public String getPartnerId();
String getPartnerId();
public String getPartnerKey();
String getPartnerKey();
public String getToken();
String getToken();
public String getAesKey();
String getAesKey();
public long getExpiresTime();
long getExpiresTime();
public String getOauth2redirectUri();
String getOauth2redirectUri();
public String getHttp_proxy_host();
String getHttp_proxy_host();
public int getHttp_proxy_port();
int getHttp_proxy_port();
public String getHttp_proxy_username();
String getHttp_proxy_username();
public String getHttp_proxy_password();
String getHttp_proxy_password();
public File getTmpDirFile();
File getTmpDirFile();
public SSLContext getSSLContext();
SSLContext getSSLContext();
/**
* http client builder
* @return ApacheHttpClientBuilder
*/
public ApacheHttpClientBuilder getApacheHttpClientBuilder();
ApacheHttpClientBuilder getApacheHttpClientBuilder();
}

View File

@@ -22,7 +22,7 @@ public interface WxMpGroupService {
*
* @param name 分组名字30个字符以内
*/
public WxMpGroup groupCreate(String name) throws WxErrorException;
WxMpGroup groupCreate(String name) throws WxErrorException;
/**
* <pre>
@@ -30,7 +30,7 @@ public interface WxMpGroupService {
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口
* </pre>
*/
public List<WxMpGroup> groupGet() throws WxErrorException;
List<WxMpGroup> groupGet() throws WxErrorException;
/**
* <pre>
@@ -40,7 +40,7 @@ public interface WxMpGroupService {
*
* @param openid 微信用户的openid
*/
public long userGetGroup(String openid) throws WxErrorException;
long userGetGroup(String openid) throws WxErrorException;
/**
* <pre>
@@ -52,7 +52,7 @@ public interface WxMpGroupService {
*
* @param group 要更新的groupgroup的id,name必须设置
*/
public void groupUpdate(WxMpGroup group) throws WxErrorException;
void groupUpdate(WxMpGroup group) throws WxErrorException;
/**
* <pre>
@@ -65,5 +65,5 @@ public interface WxMpGroupService {
* @param openid 用户openid
* @param to_groupid 移动到的分组id
*/
public void userUpdateGroup(String openid, long to_groupid) throws WxErrorException;
void userUpdateGroup(String openid, long to_groupid) throws WxErrorException;
}

View File

@@ -25,7 +25,7 @@ public interface WxMpMaterialService {
* @throws WxErrorException
* @see #mediaUpload(String, String, InputStream)
*/
public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException;
WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException;
/**
* <pre>
@@ -39,7 +39,7 @@ public interface WxMpMaterialService {
* @return 保存到本地的临时文件
* @throws WxErrorException
*/
public File mediaDownload(String media_id) throws WxErrorException;
File mediaDownload(String media_id) throws WxErrorException;
/**
* <pre>
@@ -51,7 +51,7 @@ public interface WxMpMaterialService {
* @return WxMediaImgUploadResult 返回图片url
* @throws WxErrorException
*/
public WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException;
WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException;
/**
* <pre>
@@ -72,7 +72,7 @@ public interface WxMpMaterialService {
* @param inputStream 输入流
* @throws WxErrorException
*/
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException;
WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException;
/**
* <pre>
@@ -90,7 +90,7 @@ public interface WxMpMaterialService {
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts}
* @param material 上传的素材, 请看{@link me.chanjar.weixin.mp.bean.WxMpMaterial}
*/
public WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException;
WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material) throws WxErrorException;
/**
* <pre>
@@ -101,7 +101,7 @@ public interface WxMpMaterialService {
*
* @param news 上传的图文消息, 请看{@link me.chanjar.weixin.mp.bean.WxMpMaterialNews}
*/
public WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException;
WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException;
/**
* <pre>
@@ -112,7 +112,7 @@ public interface WxMpMaterialService {
*
* @param media_id 永久素材的id
*/
public InputStream materialImageOrVoiceDownload(String media_id) throws WxErrorException;
InputStream materialImageOrVoiceDownload(String media_id) throws WxErrorException;
/**
* <pre>
@@ -123,7 +123,7 @@ public interface WxMpMaterialService {
*
* @param media_id 永久素材的id
*/
public WxMpMaterialVideoInfoResult materialVideoInfo(String media_id) throws WxErrorException;
WxMpMaterialVideoInfoResult materialVideoInfo(String media_id) throws WxErrorException;
/**
* <pre>
@@ -134,7 +134,7 @@ public interface WxMpMaterialService {
*
* @param media_id 永久素材的id
*/
public WxMpMaterialNews materialNewsInfo(String media_id) throws WxErrorException;
WxMpMaterialNews materialNewsInfo(String media_id) throws WxErrorException;
/**
* <pre>
@@ -145,7 +145,7 @@ public interface WxMpMaterialService {
*
* @param wxMpMaterialArticleUpdate 用来更新图文素材的bean, 请看{@link me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate}
*/
public boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException;
boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate) throws WxErrorException;
/**
* <pre>
@@ -156,7 +156,7 @@ public interface WxMpMaterialService {
*
* @param media_id 永久素材的id
*/
public boolean materialDelete(String media_id) throws WxErrorException;
boolean materialDelete(String media_id) throws WxErrorException;
/**
* <pre>
@@ -165,7 +165,7 @@ public interface WxMpMaterialService {
* 详情请见: http://mp.weixin.qq.com/wiki/16/8cc64f8c189674b421bee3ed403993b8.html
* </pre>
*/
public WxMpMaterialCountResult materialCount() throws WxErrorException;
WxMpMaterialCountResult materialCount() throws WxErrorException;
/**
* <pre>
@@ -177,7 +177,7 @@ public interface WxMpMaterialService {
* @param offset 从全部素材的该偏移位置开始返回0表示从第一个素材 返回
* @param count 返回素材的数量取值在1到20之间
*/
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException;
WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException;
/**
* <pre>
@@ -190,6 +190,6 @@ public interface WxMpMaterialService {
* @param offset 从全部素材的该偏移位置开始返回0表示从第一个素材 返回
* @param count 返回素材的数量取值在1到20之间
*/
public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException;
WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException;
}

View File

@@ -18,7 +18,7 @@ public interface WxMpMenuService {
* 详情请见:http://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html
* </pre>
*/
public void menuCreate(WxMenu menu) throws WxErrorException;
void menuCreate(WxMenu menu) throws WxErrorException;
/**
* <pre>
@@ -26,7 +26,7 @@ public interface WxMpMenuService {
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口
* </pre>
*/
public void menuDelete() throws WxErrorException;
void menuDelete() throws WxErrorException;
/**
* <pre>
@@ -36,7 +36,7 @@ public interface WxMpMenuService {
*
* @param menuid
*/
public void menuDelete(String menuid) throws WxErrorException;
void menuDelete(String menuid) throws WxErrorException;
/**
* <pre>
@@ -44,7 +44,7 @@ public interface WxMpMenuService {
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口
* </pre>
*/
public WxMenu menuGet() throws WxErrorException;
WxMenu menuGet() throws WxErrorException;
/**
* <pre>
@@ -54,6 +54,6 @@ public interface WxMpMenuService {
*
* @param userid 可以是粉丝的OpenID也可以是粉丝的微信号。
*/
public WxMenu menuTryMatch(String userid) throws WxErrorException;
WxMenu menuTryMatch(String userid) throws WxErrorException;
}

View File

@@ -21,9 +21,9 @@ public interface WxMpMessageHandler {
* @param sessionManager
* @return xml格式的消息如果在异步规则里处理的话可以返回null
*/
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context,
WxMpService wxMpService,
WxSessionManager sessionManager) throws WxErrorException;
WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context,
WxMpService wxMpService,
WxSessionManager sessionManager) throws WxErrorException;
}

View File

@@ -22,9 +22,9 @@ public interface WxMpMessageInterceptor {
* @param sessionManager
* @return true代表OKfalse代表不OK
*/
public boolean intercept(WxMpXmlMessage wxMessage,
Map<String, Object> context,
WxMpService wxMpService,
WxSessionManager sessionManager) throws WxErrorException;
boolean intercept(WxMpXmlMessage wxMessage,
Map<String, Object> context,
WxMpService wxMpService,
WxSessionManager sessionManager) throws WxErrorException;
}

View File

@@ -11,6 +11,6 @@ public interface WxMpMessageMatcher {
* 消息是否匹配某种模式
* @param message
*/
public boolean match(WxMpXmlMessage message);
boolean match(WxMpXmlMessage message);
}

View File

@@ -209,10 +209,7 @@ public class WxMpMessageRouter {
messageId.append(wxMessage.getMsgId());
}
if (messageDuplicateChecker.isDuplicate(messageId.toString())) {
return true;
}
return false;
return messageDuplicateChecker.isDuplicate(messageId.toString());
}

View File

@@ -21,7 +21,7 @@ public interface WxMpQrcodeService {
* @param scene_id 参数。
* @param expire_seconds 过期秒数默认60秒最小60秒最大1800秒
*/
public WxMpQrCodeTicket qrCodeCreateTmpTicket(int scene_id, Integer expire_seconds) throws WxErrorException;
WxMpQrCodeTicket qrCodeCreateTmpTicket(int scene_id, Integer expire_seconds) throws WxErrorException;
/**
* <pre>
@@ -31,7 +31,7 @@ public interface WxMpQrcodeService {
*
* @param scene_id 参数。永久二维码时最大值为100000目前参数只支持1--100000
*/
public WxMpQrCodeTicket qrCodeCreateLastTicket(int scene_id) throws WxErrorException;
WxMpQrCodeTicket qrCodeCreateLastTicket(int scene_id) throws WxErrorException;
/**
* <pre>
@@ -41,7 +41,7 @@ public interface WxMpQrcodeService {
*
* @param scene_str 参数。字符串类型长度现在为1到64
*/
public WxMpQrCodeTicket qrCodeCreateLastTicket(String scene_str) throws WxErrorException;
WxMpQrCodeTicket qrCodeCreateLastTicket(String scene_str) throws WxErrorException;
/**
* <pre>
@@ -51,7 +51,7 @@ public interface WxMpQrcodeService {
*
* @param ticket 二维码ticket
*/
public File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException;
File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException;
/**
* <pre>
@@ -62,7 +62,7 @@ public interface WxMpQrcodeService {
* @param ticket 二维码ticket
* @param needShortUrl 是否需要压缩的二维码地址
*/
public String qrCodePictureUrl(String ticket, boolean needShortUrl) throws WxErrorException;
String qrCodePictureUrl(String ticket, boolean needShortUrl) throws WxErrorException;
/**
* <pre>
@@ -72,6 +72,6 @@ public interface WxMpQrcodeService {
*
* @param ticket 二维码ticket
*/
public String qrCodePictureUrl(String ticket) throws WxErrorException;
String qrCodePictureUrl(String ticket) throws WxErrorException;
}

View File

@@ -25,7 +25,7 @@ public interface WxMpUserService {
* @param openid 用户openid
* @param remark 备注名
*/
public void userUpdateRemark(String openid, String remark) throws WxErrorException;
void userUpdateRemark(String openid, String remark) throws WxErrorException;
/**
* <pre>
@@ -36,7 +36,7 @@ public interface WxMpUserService {
* @param openid 用户openid
* @param lang 语言zh_CN 简体(默认)zh_TW 繁体en 英语
*/
public WxMpUser userInfo(String openid, String lang) throws WxErrorException;
WxMpUser userInfo(String openid, String lang) throws WxErrorException;
/**
* <pre>
@@ -46,7 +46,7 @@ public interface WxMpUserService {
*
* @param next_openid 可选第一个拉取的OPENIDnull为从头开始拉取
*/
public WxMpUserList userList(String next_openid) throws WxErrorException;
WxMpUserList userList(String next_openid) throws WxErrorException;
/**
* <pre>

View File

@@ -24,7 +24,7 @@ public class MaterialDeleteRequestExecutor implements RequestExecutor<Boolean, S
super();
}
public Boolean execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
public Boolean execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

View File

@@ -25,7 +25,7 @@ public class MaterialNewsInfoRequestExecutor implements RequestExecutor<WxMpMate
super();
}
public WxMpMaterialNews execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
public WxMpMaterialNews execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

View File

@@ -23,7 +23,7 @@ import java.util.Map;
public class MaterialUploadRequestExecutor implements RequestExecutor<WxMpMaterialUploadResult, WxMpMaterial> {
@Override
public WxMpMaterialUploadResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, WxMpMaterial material) throws WxErrorException, ClientProtocolException, IOException {
public WxMpMaterialUploadResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, WxMpMaterial material) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig response = RequestConfig.custom().setProxy(httpProxy).build();

View File

@@ -24,7 +24,7 @@ public class MaterialVideoInfoRequestExecutor implements RequestExecutor<WxMpMat
super();
}
public WxMpMaterialVideoInfoResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
public WxMpMaterialVideoInfoResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

View File

@@ -34,7 +34,7 @@ public class MaterialVoiceAndImageDownloadRequestExecutor implements RequestExec
this.tmpDirFile = tmpDirFile;
}
public InputStream execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, ClientProtocolException, IOException {
public InputStream execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

View File

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

View File

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

View File

@@ -18,7 +18,7 @@ public class WxLongTimeJsonSerializer extends JsonSerializer<Long> {
@Override
public void serialize(Long value, JsonGenerator gen,
SerializerProvider serializers)
throws IOException, JsonProcessingException {
throws IOException {
gen.writeString(DF.format(value * 1000));
}
}

View File

@@ -21,7 +21,7 @@ public class WxMpUserGsonAdapter implements JsonDeserializer<WxMpUser> {
WxMpUser wxMpUser = new WxMpUser();
Integer subscribe = GsonHelper.getInteger(o, "subscribe");
if (subscribe != null) {
wxMpUser.setSubscribe(new Integer(0).equals(subscribe) ? false : true);
wxMpUser.setSubscribe(!new Integer(0).equals(subscribe));
}
wxMpUser.setCity(GsonHelper.getString(o, "city"));
wxMpUser.setCountry(GsonHelper.getString(o, "country"));

View File

@@ -49,7 +49,6 @@ public class WxMpMessageRouterTest {
}
}).handler(new WxEchoMpMessageHandler(sb, "matcher")).end()
.rule().async(async).handler(new WxEchoMpMessageHandler(sb, "ALL")).end();
;
}
@Test(dataProvider="messages-1")