WebPath { public MatchResult match(String method, String path) { if (!httpMethod.equals(method)) { return MatchResult.NO_MATCH; } Matcher matcher = pattern.matcher(path); if (matcher.matches()) { ImmutableMap.Builder<String, String> variablesBuilder = ImmutableMap.builder(); for (int x = 0; x < variableNames.size(); ++x) { String variable = matcher.group(x + 1); variablesBuilder.put(variableNames.get(x), decode(variable)); } return new MatchResult(true, variablesBuilder.build()); } return MatchResult.NO_MATCH; } WebPath(String httpMethod, String path); MatchResult match(String method, String path); @Override String toString();  }
@Test public void decodeVariables() { WebPath webPath = new WebPath("GET", "/one/{two}/{three}"); MatchResult match = webPath.match("GET", "/one/a%20b/+c"); assertEquals("a b", match.getVariables().get("two")); assertEquals(" c", match.getVariables().get("three")); }