zouyu
8 天以前 bf95078dab81dcd0639fdb1a41e998b31c940fb1
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
135
136
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
package com.chinaztt.mes.docx.util;
 
import com.chinaztt.mes.docx.constant.CommonConstants;
 
import java.io.Serializable;
 
/**
 * 通用返回对象
 * @param <T>
 */
public class Result<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    // "返回标记:成功标记=0,失败标记=1"
    private int code;
    // "返回信息"
    private String msg;
    // "数据"
    private T data;
 
    public static <T> Result<T> ok() {
        return restResult(null, CommonConstants.SUCCESS, (String) null);
    }
 
    public static <T> Result<T> ok(T data) {
        return restResult(data, CommonConstants.SUCCESS, (String) null);
    }
 
    public static <T> Result<T> ok(T data, String msg) {
        return restResult(data, CommonConstants.SUCCESS, msg);
    }
 
    public static <T> Result<T> failed() {
        return restResult(null, CommonConstants.FAIL, (String) null);
    }
 
    public static <T> Result<T> failed(String msg) {
        return restResult(null, CommonConstants.FAIL, msg);
    }
 
    public static <T> Result<T> failed(T data) {
        return restResult(data, CommonConstants.FAIL, (String) null);
    }
 
    public static <T> Result<T> failed(T data, String msg) {
        return restResult(data, CommonConstants.FAIL, msg);
    }
 
    private static <T> Result<T> restResult(T data, int code, String msg) {
        Result<T> apiResult = new Result();
        apiResult.setCode(code);
        apiResult.setData(data);
        apiResult.setMsg(msg);
        return apiResult;
    }
 
    public static <T> RBuilder<T> builder() {
        return new RBuilder();
    }
 
    public String toString() {
        return "R(code=" + this.getCode() + ", msg=" + this.getMsg() + ", data=" + this.getData() + ")";
    }
 
    public Result() {
    }
 
    public Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
 
    public int getCode() {
        return this.code;
    }
 
    public Result<T> setCode(int code) {
        this.code = code;
        return this;
    }
 
    public String getMsg() {
        return this.msg;
    }
 
    public Result<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }
 
    public T getData() {
        return this.data;
    }
 
    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }
 
    public static class RBuilder<T> {
        private int code;
        private String msg;
        private T data;
 
        RBuilder() {
        }
 
        public RBuilder<T> code(int code) {
            this.code = code;
            return this;
        }
 
        public RBuilder<T> msg(String msg) {
            this.msg = msg;
            return this;
        }
 
        public RBuilder<T> data(T data) {
            this.data = data;
            return this;
        }
 
        public Result<T> build() {
            return new Result(this.code, this.msg, this.data);
        }
 
        public String toString() {
            return "R.RBuilder(code=" + this.code + ", msg=" + this.msg + ", data=" + this.data + ")";
        }
    }
}