### Question:
NamedVariablePatternMatcher implements PatternMatcher<NamedVariablePatternMatcher.CompiledPattern> { public boolean match(Map<String, String> map, String data, CompiledPattern expr) { if (data != null && data.length() > 0) { Matcher matcher = expr.getPattern().matcher(data); if (matcher.matches()) { for (int x=0; x<expr.getVariableNames().size(); x++) { map.put(expr.getVariableNames().get(x), matcher.group(x+1)); } return true; } } return false; }  boolean isLiteral(String pattern); CompiledPattern compilePattern(String data); boolean match(Map<String, String> map, String data, CompiledPattern expr);  }### Answer:
@Test public void testMatch() { NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher(); Map<String, String> vars = new HashMap<>(); CompiledPattern pattern = new CompiledPattern(Pattern.compile("foo([^/]+)"), Arrays.asList("bar")); assertTrue(matcher.match(vars, "foobaz", pattern)); assertEquals("baz", vars.get("bar")); }