1 package com.foxinmy.weixin4j.mp.model;
2
3 import java.io.Serializable;
4 import java.util.Arrays;
5 import java.util.List;
6
7
8
9
10
11
12
13
14
15 public final class AuthorizerOption implements Serializable {
16
17 private static final long serialVersionUID = -3124882411789627403L;
18
19
20
21
22
23
24
25
26
27 public enum AuthorizerOptionName {
28
29
30
31 location_report,
32
33
34
35 voice_recognize,
36
37
38
39 customer_service;
40 }
41
42 private AuthorizerOptionName name;
43 private int value;
44 private List<Integer> options;
45
46 private AuthorizerOption(AuthorizerOptionName name, int value,
47 Integer... options) {
48 this.name = name;
49 this.value = value;
50 this.options = Arrays.asList(options);
51 }
52
53
54
55
56
57
58
59
60 public static AuthorizerOption createLocationReportOption(int value) {
61 return new AuthorizerOption(AuthorizerOptionName.location_report,
62 value, 0, 1, 2);
63 }
64
65
66
67
68
69
70
71
72 public static AuthorizerOption createVoiceRecognizeOption(int value) {
73 return new AuthorizerOption(AuthorizerOptionName.voice_recognize,
74 value, 0, 1);
75 }
76
77
78
79
80
81
82
83
84 public static AuthorizerOption createCustomerServiceOption(int value) {
85 return new AuthorizerOption(AuthorizerOptionName.customer_service,
86 value, 0, 1);
87 }
88
89
90
91
92
93
94
95
96
97
98 public static AuthorizerOption parse(AuthorizerOptionName optionName,
99 int optionValue) {
100 if (optionName == AuthorizerOptionName.customer_service) {
101 return createCustomerServiceOption(optionValue);
102 } else if (optionName == AuthorizerOptionName.location_report) {
103 return createLocationReportOption(optionValue);
104 } else if (optionName == AuthorizerOptionName.voice_recognize) {
105 return createVoiceRecognizeOption(optionValue);
106 } else {
107 throw new IllegalArgumentException("unkown option:" + optionName);
108 }
109 }
110
111 public AuthorizerOptionName getName() {
112 return name;
113 }
114
115 public int getValue() {
116 return value;
117 }
118
119 public List<Integer> getOptions() {
120 return options;
121 }
122
123 @Override
124 public String toString() {
125 return "AuthorizerOption [name=" + name + ", value=" + value
126 + ", options=" + options + "]";
127 }
128 }