Message.java
1.57 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
package com.diligrp.assistant.shared.domain;
import com.diligrp.assistant.shared.ErrorCode;
public class Message<T> {
protected static final int CODE_SUCCESS = 200;
protected static final int CODE_FAILURE = ErrorCode.SYSTEM_UNKNOWN_ERROR;
protected static final String MSG_SUCCESS = "success";
private Integer code;
private String message;
private T data;
public Message() {
}
public Integer getCode() {
return this.code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return this.data;
}
public void setData(T data) {
this.data = data;
}
public static Message<?> success() {
Message<?> result = new Message();
result.code = 200;
result.message = "success";
return result;
}
public static <E> Message<E> success(E data) {
Message<E> result = new Message();
result.code = 200;
result.data = data;
result.message = "success";
return result;
}
public static Message<?> failure(String message) {
Message<?> result = new Message();
result.code = 1000;
result.message = message;
return result;
}
public static Message<?> failure(int code, String message) {
Message<?> result = new Message();
result.code = code;
result.message = message;
return result;
}
}