RouteParameter { static public Map<String, RouteParameter> parse(String path) { Map<String,RouteParameter> params = new LinkedHashMap<>(); Matcher matcher = Route.PATTERN_FOR_VARIABLE_PARTS_OF_ROUTE.matcher(path); while (matcher.find()) { RouteParameter param = new RouteParameter( matcher.start(0), matcher.group(0), matcher.group(1), matcher.group(3)); params.put(param.getName(), param); } return params; } RouteParameter(int index, String token, String name, String regex); int getIndex(); String getToken(); String getName(); String getRegex(); static Map<String, RouteParameter> parse(String path);  }
@Test public void parse() { Map<String,RouteParameter> params; RouteParameter param; params = RouteParameter.parse("/user"); assertThat(params, aMapWithSize(0)); params = RouteParameter.parse("/user/{id}/{email: [0-9]+}"); param = params.get("id"); assertThat(param.getName(), is("id")); assertThat(param.getToken(), is("{id}")); assertThat(param.getRegex(), is(nullValue())); param = params.get("email"); assertThat(param.getName(), is("email")); assertThat(param.getToken(), is("{email: [0-9]+}")); assertThat(param.getRegex(), is("[0-9]+")); }