Selaa lähdekoodia

:art: 修复代码

Binary Wang 1 vuosi sitten
vanhempi
commit
cb7efb79cf

+ 6 - 5
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/converter/WxPayOrderNotifyResultConverter.java

@@ -110,8 +110,11 @@ public class WxPayOrderNotifyResultConverter extends AbstractReflectionConverter
     Object val = context.convertAnother(obj, field.getType());
     try {
       if (val != null) {
-        //这里加一个看似多余的(String)强转可解决高jdk版本下的编译报错问题,详情见讨论https://github.com/vaadin/framework/issues/10737
-        PropertyDescriptor pd = new PropertyDescriptor(field.getName(), obj.getClass());
+        /*
+        这里加一个看似多余的(String)强转可解决高jdk版本下的编译报错问题,
+        详情见讨论https://github.com/vaadin/framework/issues/10737
+        */
+        PropertyDescriptor pd = new PropertyDescriptor((String) field.getName(), obj.getClass());
         pd.getWriteMethod().invoke(obj, val);
       }
     } catch (Exception ignored) {
@@ -129,9 +132,7 @@ public class WxPayOrderNotifyResultConverter extends AbstractReflectionConverter
 
   private WxPayOrderNotifyCoupon getElement(Map<Integer, WxPayOrderNotifyCoupon> coupons, String nodeName) {
     Integer index = Integer.valueOf(StringUtils.substringAfterLast(nodeName, "_"));
-    if (coupons.get(index) == null) {
-      coupons.put(index, new WxPayOrderNotifyCoupon());
-    }
+    coupons.computeIfAbsent(index, k -> new WxPayOrderNotifyCoupon());
 
     return coupons.get(index);
   }