RestUtils { public static String[] extractTemplateParams(String path) { if (StringUtils.isNullOrEmpty(path)) { return new String[0]; } StringList result = new StringList(); int ix = path.indexOf('{'); while (ix != -1) { int endIx = path.indexOf('}', ix); if (endIx == -1) { break; } if (endIx > ix + 1 && (ix > 0 && path.charAt(ix - 1) != '$')) { result.add(path.substring(ix + 1, endIx)); } ix = path.indexOf('{', ix + 1); } return result.toStringArray(); }  static String[] extractTemplateParams(String path); static String extractParams(String pathOrEndpoint, RestParamsPropertyHolder params, boolean keepHost); static String extractParams(String pathOrEndpoint, RestParamsPropertyHolder params, boolean keepHost, TemplateExtractionOption templateExtractionOptions); static void extractParamsFromQueryString(RestParamsPropertyHolder params, String queryString); static String expandPath(String path, RestParamsPropertyHolder params, RestRequestInterface request); static String makeSuffixParameterString(RestRequestInterface request); static String getQueryParamsString(RestRequestInterface request); static List<String> splitMultipleParameters(String paramStr, String delimiter); static List<String> splitMultipleParametersEmptyIncluded(String paramStr, String delimiter); static List<RestResource> extractAncestorsParentFirst(RestResource childResource); static String getExpandedPath(String path, RestParamsPropertyHolder params, ModelItem context);  }
@Test public void extractsTemplateParams() throws Exception { String path = "/{id}/test/{test}/test"; String[] params = RestUtils.extractTemplateParams(path); assertEquals(params.length, 2); assertEquals("id", params[0]); assertEquals("test", params[1]); }