Repository navigation
Expand file tree
/
Copy pathBaseResult.java
More file actions
61 lines (48 loc) · 1.55 KB
/
Copy pathBaseResult.java
File metadata and controls
61 lines (48 loc) · 1.55 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
package cn.jpush.api.common;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public abstract class BaseResult implements IRateLimiting {
public static final int ERROR_CODE_NONE = -1;
public static final int ERROR_CODE_OK = 0;
public static final String ERROR_MESSAGE_NONE = "None error message.";
protected static final int RESPONSE_OK = 200;
protected static Gson _gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
private ResponseWrapper responseWrapper;
public void setResponseWrapper(ResponseWrapper responseWrapper) {
this.responseWrapper = responseWrapper;
}
public String getOriginalContent() {
if (null != responseWrapper) {
return responseWrapper.responseContent;
}
return null;
}
public boolean isResultOK() {
return RESPONSE_OK == responseWrapper.responseCode;
}
@Override
public int getRateLimitQuota() {
if (null != responseWrapper) {
return responseWrapper.rateLimitQuota;
}
return 0;
}
@Override
public int getRateLimitRemaining() {
if (null != responseWrapper) {
return responseWrapper.rateLimitRemaining;
}
return 0;
}
@Override
public int getRateLimitReset() {
if (null != responseWrapper) {
return responseWrapper.rateLimitReset;
}
return 0;
}
@Override
public String toString() {
return _gson.toJson(this);
}
}