unicon.matthews.common.ErrorResponse.getMessage()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
eloc 2
1
package unicon.matthews.common;
2
3
import java.util.Date;
4
5
import org.springframework.http.HttpStatus;
6
7
/**
8
 * Error model for interacting with client.
9
 * 
10
 * @author vladimir.stankovic
11
 *
12
 * Aug 3, 2016
13
 */
14
public class ErrorResponse {
15
    // HTTP Response Status Code
16
    private final HttpStatus status;
17
18
    // General Error message
19
    private final String message;
20
21
    // Error code
22
    private final ErrorCode errorCode;
23
24
    private final Date timestamp;
25
26
    protected ErrorResponse(final String message, final ErrorCode errorCode, HttpStatus status) {
27
        this.message = message;
28
        this.errorCode = errorCode;
29
        this.status = status;
30
        this.timestamp = new java.util.Date();
31
    }
32
33
    public static ErrorResponse of(final String message, final ErrorCode errorCode, HttpStatus status) {
34
        return new ErrorResponse(message, errorCode, status);
35
    }
36
37
    public Integer getStatus() {
38
        return status.value();
39
    }
40
41
    public String getMessage() {
42
        return message;
43
    }
44
45
    public ErrorCode getErrorCode() {
46
        return errorCode;
47
    }
48
49
    public Date getTimestamp() {
50
        return timestamp;
51
    }
52
}
53