@Test public void testStripJaxRsRegex() { String hrefTemplate = UriBuilder.stripJaxRsRegex("{widgetName: [a-zA-Z][a-zA-Z_0-9]}"); Assertions.assertThat(hrefTemplate).isEqualTo("{widgetName}"); hrefTemplate = UriBuilder.stripJaxRsRegex( "/widgets/{widgetName: [a-zA-Z][a-zA-Z_0-9]}/items/{itemId: [a-zA-Z][a-zA-Z_0-9]}"); Assertions.assertThat(hrefTemplate).isEqualTo("/widgets/{widgetName}/items/{itemId}"); hrefTemplate = UriBuilder.stripJaxRsRegex( "/widgets/{widgetName: [a-zA-Z][a-zA-Z_0-9]}/items/{itemId: [a-zA-Z][a-zA-Z_0-9]}/id"); Assertions.assertThat(hrefTemplate).isEqualTo("/widgets/{widgetName}/items/{itemId}/id"); hrefTemplate = UriBuilder.stripJaxRsRegex("/widgets/{widgetName:.+}"); Assertions.assertThat(hrefTemplate).isEqualTo("/widgets/{widgetName}"); hrefTemplate = UriBuilder.stripJaxRsRegex("/widgets/{ widgetName : .+ }"); Assertions.assertThat(hrefTemplate).isEqualTo("/widgets/{widgetName}"); }
static String stripJaxRsRegex(String hrefTemplate) { Matcher m = JAX_RS_TEMPLATE_PARAMETERS.matcher(hrefTemplate); StringBuffer newHref = new StringBuffer(); while (m.find()) { m.appendReplacement(newHref, "{" + m.group(1) + "}"); } m.appendTail(newHref); return newHref.toString(); }
UriBuilder { static String stripJaxRsRegex(String hrefTemplate) { Matcher m = JAX_RS_TEMPLATE_PARAMETERS.matcher(hrefTemplate); StringBuffer newHref = new StringBuffer(); while (m.find()) { m.appendReplacement(newHref, "{" + m.group(1) + "}"); } m.appendTail(newHref); return newHref.toString(); } }
UriBuilder { static String stripJaxRsRegex(String hrefTemplate) { Matcher m = JAX_RS_TEMPLATE_PARAMETERS.matcher(hrefTemplate); StringBuffer newHref = new StringBuffer(); while (m.find()) { m.appendReplacement(newHref, "{" + m.group(1) + "}"); } m.appendTail(newHref); return newHref.toString(); } private  UriBuilder(); }
UriBuilder { static String stripJaxRsRegex(String hrefTemplate) { Matcher m = JAX_RS_TEMPLATE_PARAMETERS.matcher(hrefTemplate); StringBuffer newHref = new StringBuffer(); while (m.find()) { m.appendReplacement(newHref, "{" + m.group(1) + "}"); } m.appendTail(newHref); return newHref.toString(); } private  UriBuilder();  }
UriBuilder { static String stripJaxRsRegex(String hrefTemplate) { Matcher m = JAX_RS_TEMPLATE_PARAMETERS.matcher(hrefTemplate); StringBuffer newHref = new StringBuffer(); while (m.find()) { m.appendReplacement(newHref, "{" + m.group(1) + "}"); } m.appendTail(newHref); return newHref.toString(); } private  UriBuilder();   }