Skip to content

Commit dc33436

Browse files
committed
reformat some code
1 parent f221ea3 commit dc33436

15 files changed

+54
-118
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpCardGsonAdapter.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
package me.chanjar.weixin.mp.util.json;
22

3-
import java.lang.reflect.Type;
4-
5-
import com.google.gson.JsonDeserializationContext;
6-
import com.google.gson.JsonDeserializer;
7-
import com.google.gson.JsonElement;
8-
import com.google.gson.JsonObject;
9-
import com.google.gson.JsonParseException;
10-
3+
import com.google.gson.*;
114
import me.chanjar.weixin.common.util.json.GsonHelper;
125
import me.chanjar.weixin.mp.bean.WxMpCard;
136

7+
import java.lang.reflect.Type;
8+
149
/**
1510
* Created by YuJian on 15/11/11.
1611
*
@@ -21,7 +16,7 @@ public class WxMpCardGsonAdapter implements JsonDeserializer<WxMpCard> {
2116

2217
@Override
2318
public WxMpCard deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext
24-
jsonDeserializationContext) throws JsonParseException {
19+
jsonDeserializationContext) throws JsonParseException {
2520
WxMpCard card = new WxMpCard();
2621
JsonObject jsonObject = jsonElement.getAsJsonObject();
2722

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpCardResultGsonAdapter.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package me.chanjar.weixin.mp.util.json;
22

3-
import java.lang.reflect.Type;
4-
5-
import com.google.gson.JsonDeserializationContext;
6-
import com.google.gson.JsonDeserializer;
7-
import com.google.gson.JsonElement;
8-
import com.google.gson.JsonObject;
9-
import com.google.gson.JsonParseException;
3+
import com.google.gson.*;
104
import com.google.gson.reflect.TypeToken;
11-
125
import me.chanjar.weixin.common.util.json.GsonHelper;
136
import me.chanjar.weixin.mp.bean.WxMpCard;
147
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
158

9+
import java.lang.reflect.Type;
10+
1611
/**
1712
* Created by YuJian on 15/11/11.
1813
*
@@ -32,8 +27,8 @@ public WxMpCardResult deserialize(JsonElement jsonElement, Type type, JsonDeseri
3227
cardResult.setUserCardStatus(GsonHelper.getString(jsonObject, "user_card_status"));
3328

3429
WxMpCard card = WxMpGsonBuilder.INSTANCE.create().fromJson(jsonObject.get("card"),
35-
new TypeToken<WxMpCard>() {
36-
}.getType());
30+
new TypeToken<WxMpCard>() {
31+
}.getType());
3732

3833
cardResult.setCard(card);
3934

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpGsonBuilder.java

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,12 @@
22

33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
5-
6-
import me.chanjar.weixin.mp.bean.WxMpCard;
7-
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
8-
import me.chanjar.weixin.mp.bean.WxMpMassNews;
9-
import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
10-
import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage;
11-
import me.chanjar.weixin.mp.bean.WxMpMassTagMessage;
12-
import me.chanjar.weixin.mp.bean.WxMpMassVideo;
13-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialArticleUpdate;
14-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
5+
import me.chanjar.weixin.mp.bean.*;
156
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
167
import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
17-
import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult;
18-
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
19-
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
20-
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
21-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialCountResult;
22-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialFileBatchGetResult;
23-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNewsBatchGetResult;
24-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult;
25-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
26-
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
27-
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
28-
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
29-
import me.chanjar.weixin.mp.bean.result.WxMpUser;
30-
import me.chanjar.weixin.mp.bean.result.WxMpUserBlacklistGetResult;
31-
import me.chanjar.weixin.mp.bean.result.WxMpUserList;
8+
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
9+
import me.chanjar.weixin.mp.bean.material.*;
10+
import me.chanjar.weixin.mp.bean.result.*;
3211
import me.chanjar.weixin.mp.bean.template.WxMpTemplateIndustry;
3312
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
3413

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpIndustryGsonAdapter.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
* @author miller
1111
*/
1212
public class WxMpIndustryGsonAdapter
13-
implements JsonSerializer<WxMpTemplateIndustry>, JsonDeserializer<WxMpTemplateIndustry> {
13+
implements JsonSerializer<WxMpTemplateIndustry>, JsonDeserializer<WxMpTemplateIndustry> {
14+
private static WxMpTemplateIndustry.Industry convertFromJson(JsonObject json) {
15+
WxMpTemplateIndustry.Industry industry = new WxMpTemplateIndustry.Industry();
16+
industry.setFirstClass(GsonHelper.getString(json, "first_class"));
17+
industry.setSecondClass(GsonHelper.getString(json, "second_class"));
18+
return industry;
19+
}
20+
1421
@Override
1522
public JsonElement serialize(WxMpTemplateIndustry wxMpIndustry, Type type,
16-
JsonSerializationContext jsonSerializationContext) {
23+
JsonSerializationContext jsonSerializationContext) {
1724
JsonObject json = new JsonObject();
1825
json.addProperty("industry_id1", wxMpIndustry.getPrimaryIndustry().getId());
1926
json.addProperty("industry_id2", wxMpIndustry.getSecondIndustry().getId());
@@ -22,22 +29,15 @@ public JsonElement serialize(WxMpTemplateIndustry wxMpIndustry, Type type,
2229

2330
@Override
2431
public WxMpTemplateIndustry deserialize(JsonElement jsonElement, Type type,
25-
JsonDeserializationContext jsonDeserializationContext)
26-
throws JsonParseException {
32+
JsonDeserializationContext jsonDeserializationContext)
33+
throws JsonParseException {
2734
WxMpTemplateIndustry wxMpIndustry = new WxMpTemplateIndustry();
2835
JsonObject primaryIndustry = jsonElement.getAsJsonObject()
29-
.get("primary_industry").getAsJsonObject();
36+
.get("primary_industry").getAsJsonObject();
3037
wxMpIndustry.setPrimaryIndustry(convertFromJson(primaryIndustry));
3138
JsonObject secondaryIndustry = jsonElement.getAsJsonObject()
32-
.get("secondary_industry").getAsJsonObject();
39+
.get("secondary_industry").getAsJsonObject();
3340
wxMpIndustry.setSecondIndustry(convertFromJson(secondaryIndustry));
3441
return wxMpIndustry;
3542
}
36-
37-
private static WxMpTemplateIndustry.Industry convertFromJson(JsonObject json) {
38-
WxMpTemplateIndustry.Industry industry = new WxMpTemplateIndustry.Industry();
39-
industry.setFirstClass(GsonHelper.getString(json, "first_class"));
40-
industry.setSecondClass(GsonHelper.getString(json, "second_class"));
41-
return industry;
42-
}
4343
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpKefuMessageGsonAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public JsonElement serialize(WxMpKefuMessage message, Type typeOfSrc, JsonSerial
8787
messageJson.add("wxcard", wxcard);
8888
}
8989

90-
if (StringUtils.isNotBlank(message.getKfAccount())){
90+
if (StringUtils.isNotBlank(message.getKfAccount())) {
9191
JsonObject newsJsonObject = new JsonObject();
9292
newsJsonObject.addProperty("kf_account", message.getKfAccount());
9393
messageJson.add("customservice", newsJsonObject);

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassUploadResultAdapter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
import java.lang.reflect.Type;
1616

1717
/**
18-
*
1918
* @author Daniel Qian
20-
*
2119
*/
2220
public class WxMpMassUploadResultAdapter implements JsonDeserializer<WxMpMassUploadResult> {
2321

@@ -37,5 +35,5 @@ public WxMpMassUploadResult deserialize(JsonElement json, Type typeOfT, JsonDese
3735
}
3836
return uploadResult;
3937
}
40-
38+
4139
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMassVideoAdapter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
import java.lang.reflect.Type;
1818

1919
/**
20-
*
2120
* @author Daniel Qian
22-
*
2321
*/
2422
public class WxMpMassVideoAdapter implements JsonSerializer<WxMpMassVideo> {
2523

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpMaterialNewsArticleGsonAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public JsonElement serialize(WxMpMaterialNews.WxMpMaterialNewsArticle article, T
2121
JsonObject articleJson = new JsonObject();
2222

2323
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
24-
articleJson.addProperty("thumb_url",article.getThumbUrl());
24+
articleJson.addProperty("thumb_url", article.getThumbUrl());
2525
articleJson.addProperty("title", article.getTitle());
2626
articleJson.addProperty("content", article.getContent());
2727
if (null != article.getAuthor()) {
@@ -70,7 +70,7 @@ public WxMpMaterialNews.WxMpMaterialNewsArticle deserialize(JsonElement jsonElem
7070
article.setThumbMediaId(GsonHelper.getAsString(thumbMediaId));
7171
}
7272
JsonElement thumbUrl = articleInfo.get("thumb_url");
73-
if(thumbUrl != null && !thumbUrl.isJsonNull()) {
73+
if (thumbUrl != null && !thumbUrl.isJsonNull()) {
7474
article.setThumbUrl(GsonHelper.getAsString(thumbUrl));
7575
}
7676
JsonElement showCoverPic = articleInfo.get("show_cover_pic");

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpOAuth2AccessTokenAdapter.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
package me.chanjar.weixin.mp.util.json;
22

3-
import java.lang.reflect.Type;
4-
5-
import com.google.gson.JsonDeserializationContext;
6-
import com.google.gson.JsonDeserializer;
7-
import com.google.gson.JsonElement;
8-
import com.google.gson.JsonObject;
9-
import com.google.gson.JsonParseException;
10-
3+
import com.google.gson.*;
114
import me.chanjar.weixin.common.util.json.GsonHelper;
125
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
136

7+
import java.lang.reflect.Type;
8+
149
public class WxMpOAuth2AccessTokenAdapter implements JsonDeserializer<WxMpOAuth2AccessToken> {
1510

1611
@Override
1712
public WxMpOAuth2AccessToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws
18-
JsonParseException {
13+
JsonParseException {
1914
WxMpOAuth2AccessToken accessToken = new WxMpOAuth2AccessToken();
2015
JsonObject accessTokenJsonObject = json.getAsJsonObject();
2116

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/json/WxMpSemanticQueryResultAdapter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
import java.lang.reflect.Type;
1616

1717
/**
18-
*
1918
* @author Daniel Qian
20-
*
2119
*/
2220
public class WxMpSemanticQueryResultAdapter implements JsonDeserializer<WxMpSemanticQueryResult> {
2321

@@ -46,5 +44,5 @@ public WxMpSemanticQueryResult deserialize(JsonElement json, Type typeOfT, JsonD
4644
}
4745
return result;
4846
}
49-
47+
5048
}

0 commit comments

Comments
 (0)