blob: 8b958de86a9986ed5c5d2ae88b54d168802a310a [file] [log] [blame]
Ray Milkeyfbfd2da2014-05-09 17:30:14 -07001package net.onrc.onos.api.rest;
2
3/**
4 * Describes a REST error.
5 * code is a unique identifier for the error.
6 * summary is indended to be a short description of what happened.
7 * description is a long description of the problem, and can be formatted using
8 * variable replacement. Variable placeholders are indicated with the string
9 * "{}" in the description.
10 * Objects of this class are immutable.
11 */
12
13public final class RestError {
14
15 private final RestErrorCodes.RestErrorCode code;
16 private final String summary;
17 private final String description;
18
19 /**
20 * Constructs a new RestError object from a code, summary and description.
21 *
22 * @param newCode code for the new error
23 * @param newSummary short summary for the new error
24 * @param newDescription formatable description for the new error
25 */
26 public RestError(final RestErrorCodes.RestErrorCode newCode,
27 final String newSummary,
28 final String newDescription) {
29 code = newCode;
30 summary = newSummary;
31 description = newDescription;
32 }
33
34 /**
35 * Gets the summary of the error.
36 *
37 * @return string for the summary
38 */
39 public String getSummary() {
40 return summary;
41 }
42
43 /**
44 * Gets the unique code for this error.
45 *
46 * @return unique code
47 */
48 public RestErrorCodes.RestErrorCode getCode() {
49 return code;
50 }
51
52 /**
53 * Gets the unformatted description string for the error.
54 *
55 * @return the unformatted description string.
56 */
57 public String getDescription() {
58 return description;
59 }
60}