@Test public void testGroups() throws Exception { Map<String, String> group1 = Route.build("/api/people/:person").groups("/api/people/jeff"); assertEquals(group1.get("person"), "jeff"); Map<String, String> group2 = Route.build("/api/people/:person/hands/:hand/slap") .groups("/api/people/jeff/hands/left/slap"); assertEquals(group2.get("person"), "jeff"); assertEquals(group2.get("hand"), "left"); }
public Map<String, String> groups(String path) { Matcher matcher = pathPattern.matcher(path); Map<String, String> groups = new HashMap<>(); if (matcher.matches()) { for (String keyword : keywords) { groups.put(keyword, matcher.group(keyword)); } } return groups; }
Route { public Map<String, String> groups(String path) { Matcher matcher = pathPattern.matcher(path); Map<String, String> groups = new HashMap<>(); if (matcher.matches()) { for (String keyword : keywords) { groups.put(keyword, matcher.group(keyword)); } } return groups; } }
Route { public Map<String, String> groups(String path) { Matcher matcher = pathPattern.matcher(path); Map<String, String> groups = new HashMap<>(); if (matcher.matches()) { for (String keyword : keywords) { groups.put(keyword, matcher.group(keyword)); } } return groups; } private  Route(String path, Pattern pathPattern, List<String> keywords); }
Route { public Map<String, String> groups(String path) { Matcher matcher = pathPattern.matcher(path); Map<String, String> groups = new HashMap<>(); if (matcher.matches()) { for (String keyword : keywords) { groups.put(keyword, matcher.group(keyword)); } } return groups; } private  Route(String path, Pattern pathPattern, List<String> keywords); static Pattern compile(String pattern, List<String> keywords); static Route build(String pattern); Pattern pathPattern(); boolean matches(String path); Map<String, String> groups(String path); @Override boolean equals(final Object o); @Override int hashCode(); }
Route { public Map<String, String> groups(String path) { Matcher matcher = pathPattern.matcher(path); Map<String, String> groups = new HashMap<>(); if (matcher.matches()) { for (String keyword : keywords) { groups.put(keyword, matcher.group(keyword)); } } return groups; } private  Route(String path, Pattern pathPattern, List<String> keywords); static Pattern compile(String pattern, List<String> keywords); static Route build(String pattern); Pattern pathPattern(); boolean matches(String path); Map<String, String> groups(String path); @Override boolean equals(final Object o); @Override int hashCode();  }