WebPreferencesResponse.java
2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package com.mumfrey.webprefs.framework;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.mumfrey.webprefs.interfaces.IWebPreferencesResponse;
class WebPreferencesResponse implements IWebPreferencesResponse
{
private static final long serialVersionUID = 1L;
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
@Expose @SerializedName("response")
private String response;
@Expose @SerializedName("message")
private String message;
@Expose @SerializedName("uuid")
private String uuid;
@Expose @SerializedName("serverid")
private String serverId;
@Expose @SerializedName("rate")
private int rateLimit;
@Expose @SerializedName("get")
private Map<String, String> get;
@Expose @SerializedName("set")
private List<String> set;
private transient Throwable th;
public WebPreferencesResponse() {}
private WebPreferencesResponse(String response, Throwable th)
{
this.response = response;
this.th = th;
}
@Override
public String getResponse()
{
return this.response;
}
@Override
public String getMessage()
{
return this.message;
}
@Override
public Throwable getThrowable()
{
return this.th;
}
@Override
public String getUUID()
{
return this.uuid;
}
@Override
public String getServerId()
{
return this.serverId;
}
@Override
public boolean hasValues()
{
return this.get != null;
}
@Override
public Map<String, String> getValues()
{
return this.get;
}
@Override
public boolean hasSetters()
{
return this.set != null;
}
@Override
public Set<String> getSetters()
{
return new HashSet<String>(this.set);
}
public static IWebPreferencesResponse fromJson(String json)
{
try
{
return WebPreferencesResponse.gson.fromJson(json, WebPreferencesResponse.class);
}
catch (JsonSyntaxException ex)
{
return new WebPreferencesResponse("500 Invalid JSON", ex);
}
catch (Throwable th)
{
return new WebPreferencesResponse("500 Invalid JSON", th);
}
}
@Override
public String toString()
{
try
{
return WebPreferencesResponse.gson.toJson(this);
}
catch (Throwable th)
{
return "{\"Invalid JSON\"}";
}
}
}