Bladeren bron

refactor: Use diamond operator

Kyle Scully 3 jaren geleden
bovenliggende
commit
0bcba32ea4

+ 2 - 2
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/WxDnsResolver.java

@@ -19,7 +19,7 @@ import java.util.Map;
 public class WxDnsResolver implements DnsResolver {
 
   private final static String WECHAT_API_URL = "api.weixin.qq.com";
-  private static Map<String, InetAddress[]> MAPPINGS = new HashMap<String, InetAddress[]>();
+  private static Map<String, InetAddress[]> MAPPINGS = new HashMap<>();
   protected final Logger log = LoggerFactory.getLogger(WxDnsResolver.class);
   private String wxApiIp;
 
@@ -38,7 +38,7 @@ public class WxDnsResolver implements DnsResolver {
     } catch (UnknownHostException e) {
       //如果初始化DNS配置失败则使用默认配置,不影响服务的启动
       log.error("init WxDnsResolver error", e);
-      MAPPINGS = new HashMap<String, InetAddress[]>();
+      MAPPINGS = new HashMap<>();
     }
 
   }

+ 1 - 1
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java

@@ -79,7 +79,7 @@ public abstract class AbstractWxMaRedisConfig extends WxMaDefaultConfigImpl {
 
   private void setValueToRedis(String key, long expiresTime, String value) {
     try (Jedis jedis = getConfiguredJedis()) {
-      Map<String, String> hash = new HashMap<String, String>();
+      Map<String, String> hash = new HashMap<>();
       hash.put(HASH_VALUE_FIELD, value);
       hash.put(HASH_EXPIRE_FIELD, String.valueOf(expiresTime));
       jedis.hmset(getRedisKey(key), hash);

+ 8 - 8
weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImplTest.java

@@ -33,23 +33,23 @@ public class WxMaShopAuditServiceImplTest {
     WxMaShopAuditBrandRequest request = WxMaShopAuditBrandRequest.builder().build();
     WxMaShopAuditBrandRequest.AuditReqBean auditReqBean = WxMaShopAuditBrandRequest.AuditReqBean.builder().build();
 
-    auditReqBean.setLicense(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")));
+    auditReqBean.setLicense(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")));
     auditReqBean.setBrandInfo(WxMaShopAuditBrandRequest.AuditReqBean.BrandInfoBean.builder()
       .brandAuditType(1)
       .trademarkType("29")
       .brandManagementType(2)
       .commodityOriginType(2)
       .brandWording("346225226351203275")
-      .saleAuthorization(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
-      .trademarkRegistrationCertificate(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
-      .trademarkChangeCertificate(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
+      .saleAuthorization(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
+      .trademarkRegistrationCertificate(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
+      .trademarkChangeCertificate(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
       .trademarkRegistrant("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")
       .trademarkRegistrantNu("1249305")
       .trademarkAuthorizationPeriod("2020-03-25 12:05:25")
-      .trademarkRegistrationApplication(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
+      .trademarkRegistrationApplication(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
       .trademarkApplicant("张三")
       .trademarkApplicationTime("2020-03-25 12:05:25")
-      .importedGoodsForm(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
+      .importedGoodsForm(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
       .build());
     request.setAuditReq(auditReqBean);
 
@@ -61,12 +61,12 @@ public class WxMaShopAuditServiceImplTest {
   public void testAuditCategory() throws WxErrorException {
     WxMaShopAuditCategoryRequest request = WxMaShopAuditCategoryRequest.builder().build();
     WxMaShopAuditCategoryRequest.AuditReqBean auditReqBean = WxMaShopAuditCategoryRequest.AuditReqBean.builder().build();
-    auditReqBean.setLicense(new ArrayList<String>(Arrays.asList("www.xxxxx.com")));
+    auditReqBean.setLicense(new ArrayList<>(Arrays.asList("www.xxxxx.com")));
     auditReqBean.setCategoryInfo(WxMaShopAuditCategoryRequest.AuditReqBean.CategoryInfoBean.builder()
       .level1(7419)
       .level2(7439)
       .level3(7448)
-      .certificate(new ArrayList<String>(Arrays.asList("www.xxxxx.com")))
+      .certificate(new ArrayList<>(Arrays.asList("www.xxxxx.com")))
       .build());
     request.setAuditReq(auditReqBean);
     WxMaShopAuditCategoryResponse response = wxService.getShopAuditService().auditCategory(request);

+ 1 - 1
weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMessageRouter.java

@@ -17,7 +17,7 @@ public class WxOpenMessageRouter extends WxMpMessageRouter {
   }
 
   public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, String appId) {
-    return route(wxMessage, new HashMap<String, Object>(), appId);
+    return route(wxMessage, new HashMap<>(), appId);
   }
 
   public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map<String, Object> context, String appId) {