Ray Milkey | a8091b1 | 2014-05-16 14:42:47 -0700 | [diff] [blame] | 1 | package 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 | |
| 13 | public final class RestErrorCatalogEntry { |
| 14 | |
Ray Milkey | 6fdd91d | 2014-07-30 16:27:07 -0700 | [diff] [blame] | 15 | private final RestErrorCode code; |
Ray Milkey | a8091b1 | 2014-05-16 14:42:47 -0700 | [diff] [blame] | 16 | 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 Milkey | 6fdd91d | 2014-07-30 16:27:07 -0700 | [diff] [blame] | 26 | public RestErrorCatalogEntry(final RestErrorCode newCode, |
Ray Milkey | a8091b1 | 2014-05-16 14:42:47 -0700 | [diff] [blame] | 27 | 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 Milkey | 6fdd91d | 2014-07-30 16:27:07 -0700 | [diff] [blame] | 48 | public RestErrorCode getCode() { |
Ray Milkey | a8091b1 | 2014-05-16 14:42:47 -0700 | [diff] [blame] | 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 getDescriptionFormatString() { |
| 58 | return descriptionFormatString; |
| 59 | } |
| 60 | } |