blob: b9b2ba50e4e8d99c46829b7aefb70e3d70bd48f2 [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 /**
Ray Milkeya8091b12014-05-16 14:42:47 -070017 * Takes a RestErrorCatalogEntry template and formats the description using a supplied
Ray Milkeyfbfd2da2014-05-09 17:30:14 -070018 * list of replacement parameters.
19 *
Ray Milkeya8091b12014-05-16 14:42:47 -070020 * @param error the RestErrorCatalogEntry to format
Ray Milkeyfbfd2da2014-05-09 17:30:14 -070021 * @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 */
Ray Milkeya8091b12014-05-16 14:42:47 -070026 static String formatErrorMessage(final RestErrorCatalogEntry error,
Ray Milkeyfbfd2da2014-05-09 17:30:14 -070027 final Object... parameters) {
28 final FormattingTuple formattingResult =
Ray Milkeya8091b12014-05-16 14:42:47 -070029 MessageFormatter.arrayFormat(error.getDescriptionFormatString(), parameters);
Ray Milkeyfbfd2da2014-05-09 17:30:14 -070030 return formattingResult.getMessage();
31 }
32}