-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResult.java
More file actions
70 lines (55 loc) · 1.21 KB
/
Result.java
File metadata and controls
70 lines (55 loc) · 1.21 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
package io.wangxin.result;
import java.io.Serializable;
/**
* Data wrapper class returned by Api
*
* @param <T> return data
* @author Xin Wang
*/
public class Result<T> implements Serializable, Cloneable {
private static final long serialVersionUID = -4233732342342357310L;
/**
* return value
**/
private T data;
/**
* error code
*/
private int code;
/**
* error message
*/
private String message;
private static final int SUCCESS_CODE = 0;
public Result() {
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
public Result(int code, String message) {
this.code = code;
this.message = message;
}
public boolean isSuccess() {
return this.code == SUCCESS_CODE;
}
public void setCode(int code) {
this.code = code;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}