blob: f4900a32b57184be5299efc0d8022f85f2a8cc01 [file] [log] [blame]
Ray Milkeya8091b12014-05-16 14:42:47 -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 * descriptionFormatString 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 descriptionFormatString.
10 * Objects of this class are immutable.
11 */
12
13public final class RestErrorCatalogEntry {
14
Ray Milkey6fdd91d2014-07-30 16:27:07 -070015 private final RestErrorCode code;
Ray Milkeya8091b12014-05-16 14:42:47 -070016 private final String summary;
17 private final String descriptionFormatString;
18
19 /**
20 * Constructs a new RestErrorCatalogEntry object from a code, summary and descriptionFormatString.
21 *
22 * @param newCode code for the new error
23 * @param newSummary short summary for the new error
24 * @param newDescriptionFormatString formatable description for the new error
25 */
Ray Milkey6fdd91d2014-07-30 16:27:07 -070026 public RestErrorCatalogEntry(final RestErrorCode newCode,
Ray Milkeya8091b12014-05-16 14:42:47 -070027 final String newSummary,
28 final String newDescriptionFormatString) {
29 code = newCode;
30 summary = newSummary;
31 descriptionFormatString = newDescriptionFormatString;
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 */
Ray Milkey6fdd91d2014-07-30 16:27:07 -070048 public RestErrorCode getCode() {
Ray Milkeya8091b12014-05-16 14:42:47 -070049 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 getDescriptionFormatString() {
58 return descriptionFormatString;
59 }
60}