blob: edc39b2b1478bb924ce3cb1622e918bfe80562a7 [file] [log] [blame]
Ray Milkeyfbfd2da2014-05-09 17:30:14 -07001package net.onrc.onos.api.rest;
2
3import org.slf4j.helpers.FormattingTuple;
4import org.slf4j.helpers.MessageFormatter;
5
6/**
7 * Utility class used for formatting Rest Error descriptions.
8 */
9public final class RestErrorFormatter {
10
11 /**
12 * Hide default constructor for utility classes.
13 */
14 private RestErrorFormatter() { }
15
16 /**
17 * Takes a RestError template and formats the description using a supplied
18 * list of replacement parameters.
19 *
20 * @param error the RestError to format
21 * @param parameters parameter list to use as positional parameters in the
22 * result string
23 *
24 * @return the String object for the formatted message.
25 */
26 static String formatErrorMessage(final RestError error,
27 final Object... parameters) {
28 final FormattingTuple formattingResult =
29 MessageFormatter.arrayFormat(error.getDescription(), parameters);
30 return formattingResult.getMessage();
31 }
32}