Java tutorial
/* * MIT License * * Copyright (c) 2016 Warren Fan * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package me.ixfan.wechatkit.user.model; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.List; /** * Wechat user model. * * @author xfan */ public class WeChatFollower { /** * ?? */ private String openid; /** * */ private String nickname; /** * 120 */ private int sex; /** * */ private String country; /** * ? */ private String province; /** * */ private String city; /** * ????0?46?64?96?132?0640*640?????URL */ private String headimgurl; /** * ??????? */ private String unionid; /** * ???????????? */ private String remark; /** * ID? */ private int groupid; /** * ID */ private int[] tagidList; /** * ??0???? */ private int subscribe; /** * ?? */ private Long subscribeTime; public WeChatFollower(String openid) { this.openid = openid; } public static WeChatFollower fromJson(JsonObject jsonObject) { Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); return gson.fromJson(jsonObject, WeChatFollower.class); } public static List<WeChatFollower> batchFromJson(JsonArray jsonArray) { Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); Type type = new TypeToken<List<WeChatFollower>>() { }.getType(); return gson.fromJson(jsonArray, type); } /** * @return (openid)?? */ public String getOpenid() { return openid; } public void setOpenid(String openid) { this.openid = openid; } /** * @return */ public String getNickname() { return nickname; } public void setNickname(String nickname) { this.nickname = nickname; } /** * @return 120 */ public int getSex() { return sex; } public void setSex(int sex) { this.sex = sex; } /** * @return */ public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } /** * @return ? */ public String getProvince() { return province; } public void setProvince(String province) { this.province = province; } /** * @return */ public String getCity() { return city; } public void setCity(String city) { this.city = city; } /** * @return ????0?46?64?96?132?0640*640?????URL */ public String getHeadimgurl() { return headimgurl; } public void setHeadimgurl(String headimgurl) { this.headimgurl = headimgurl; } /** * @return ??????? */ public String getUnionid() { return unionid; } public void setUnionid(String unionid) { this.unionid = unionid; } /** * @return ???????????? */ public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } /** * @return ID? */ public int getGroupid() { return groupid; } public void setGroupid(int groupid) { this.groupid = groupid; } /** * @return ID */ public int[] getTagidList() { return tagidList; } public void setTagidList(int[] tagidList) { this.tagidList = tagidList; } /** * @return ??0???? */ public int getSubscribe() { return subscribe; } public void setSubscribe(int subscribe) { this.subscribe = subscribe; } /** * @return ?? */ public Long getSubscribeTime() { return subscribeTime; } public void setSubscribeTime(Long subscribeTime) { this.subscribeTime = subscribeTime; } }