1 package com.foxinmy.weixin4j.model;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.Arrays;
6 import java.util.List;
7
8 import com.alibaba.fastjson.annotation.JSONField;
9 import com.foxinmy.weixin4j.type.ButtonType;
10
11
12
13
14
15
16
17
18
19
20
21
22
23 public class Button implements Serializable {
24
25 private static final long serialVersionUID = -6422234732203854866L;
26
27
28
29
30 private String name;
31
32
33
34
35
36
37
38 private String type;
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 private String content;
57
58
59
60 @JSONField(serialize = false, deserialize = false)
61 private Object extra;
62
63
64
65 private String appid;
66
67
68
69 private String pagepath;
70
71
72
73
74 @JSONField(name = "sub_button")
75 private List<Button> subs;
76
77 protected Button() {
78 this.subs = new ArrayList<Button>();
79 }
80
81
82
83
84
85
86
87
88
89 public Button(String name, Button... subButtons) {
90 this.name = name;
91 this.subs = new ArrayList<Button>(Arrays.asList(subButtons));
92 }
93
94
95
96
97
98
99
100
101
102
103
104 public Button(String name, String content, ButtonType type) {
105 this.name = name;
106 this.content = content;
107 this.type = type.name();
108 this.subs = new ArrayList<Button>();
109 }
110
111
112
113
114
115
116
117
118
119
120
121
122
123 public Button(String name, String url, String appid, String pagepath) {
124 this.name = name;
125 this.content = url;
126 this.appid = appid;
127 this.pagepath = pagepath;
128 this.type = ButtonType.miniprogram.name();
129 this.subs = new ArrayList<Button>();
130 }
131
132 public String getName() {
133 return name;
134 }
135
136 public void setName(String name) {
137 this.name = name;
138 }
139
140 public String getType() {
141 return type;
142 }
143
144 public void setType(String type) {
145 this.type = type;
146 }
147
148 public void setType(ButtonType type) {
149 this.type = type.name();
150 }
151
152 public String getContent() {
153 return content;
154 }
155
156 public void setContent(String content) {
157 this.content = content;
158 }
159
160 public Object getExtra() {
161 return extra;
162 }
163
164
165
166
167
168
169 public void setExtra(Object extra) {
170 this.extra = extra;
171 }
172
173 public String getAppid() {
174 return appid;
175 }
176
177 public void setAppid(String appid) {
178 this.appid = appid;
179 }
180
181 public String getPagepath() {
182 return pagepath;
183 }
184
185 public void setPagepath(String pagepath) {
186 this.pagepath = pagepath;
187 }
188
189 public List<Button> getSubs() {
190 return subs;
191 }
192
193 public void setSubs(List<Button> subs) {
194 this.subs = subs;
195 }
196
197 public Button pushSub(Button btn) {
198 this.subs.add(btn);
199 return this;
200 }
201
202 @Override
203 public String toString() {
204 return "Button [name=" + name + ", type=" + type + ", content=" + content + ", extra=" + extra + ", appid="
205 + appid + ", pagepath=" + pagepath + ", subs=" + subs + "]";
206 }
207 }