@Test public void testCompile() throws Exception {}
public static Pattern compile(String pattern, List<String> keywords) { StringBuilder regexPattern = new StringBuilder(); if (pattern.equals("/")) { regexPattern.append("/"); } else { final String[] segments = pattern.split("/"); for (String segment : segments) { if (!segment.equals("")) { if (keywordPattern.matcher(segment).matches()) { String keyword = segment.substring(1); if (keyword.indexOf("*") == 0) { keyword = keyword.substring(1); regexPattern.append("[/]?").append("(?<").append(keyword).append(">.*)"); } else { regexPattern.append("/").append("(?<").append(keyword).append(">[^/]*)"); } keywords.add(keyword); } else { regexPattern.append("/").append(segment); } } } } regexPattern.append("[/]?"); return Pattern.compile(regexPattern.toString()); }
Route { public static Pattern compile(String pattern, List<String> keywords) { StringBuilder regexPattern = new StringBuilder(); if (pattern.equals("/")) { regexPattern.append("/"); } else { final String[] segments = pattern.split("/"); for (String segment : segments) { if (!segment.equals("")) { if (keywordPattern.matcher(segment).matches()) { String keyword = segment.substring(1); if (keyword.indexOf("*") == 0) { keyword = keyword.substring(1); regexPattern.append("[/]?").append("(?<").append(keyword).append(">.*)"); } else { regexPattern.append("/").append("(?<").append(keyword).append(">[^/]*)"); } keywords.add(keyword); } else { regexPattern.append("/").append(segment); } } } } regexPattern.append("[/]?"); return Pattern.compile(regexPattern.toString()); } }
Route { public static Pattern compile(String pattern, List<String> keywords) { StringBuilder regexPattern = new StringBuilder(); if (pattern.equals("/")) { regexPattern.append("/"); } else { final String[] segments = pattern.split("/"); for (String segment : segments) { if (!segment.equals("")) { if (keywordPattern.matcher(segment).matches()) { String keyword = segment.substring(1); if (keyword.indexOf("*") == 0) { keyword = keyword.substring(1); regexPattern.append("[/]?").append("(?<").append(keyword).append(">.*)"); } else { regexPattern.append("/").append("(?<").append(keyword).append(">[^/]*)"); } keywords.add(keyword); } else { regexPattern.append("/").append(segment); } } } } regexPattern.append("[/]?"); return Pattern.compile(regexPattern.toString()); } private  Route(String path, Pattern pathPattern, List<String> keywords); }
Route { public static Pattern compile(String pattern, List<String> keywords) { StringBuilder regexPattern = new StringBuilder(); if (pattern.equals("/")) { regexPattern.append("/"); } else { final String[] segments = pattern.split("/"); for (String segment : segments) { if (!segment.equals("")) { if (keywordPattern.matcher(segment).matches()) { String keyword = segment.substring(1); if (keyword.indexOf("*") == 0) { keyword = keyword.substring(1); regexPattern.append("[/]?").append("(?<").append(keyword).append(">.*)"); } else { regexPattern.append("/").append("(?<").append(keyword).append(">[^/]*)"); } keywords.add(keyword); } else { regexPattern.append("/").append(segment); } } } } regexPattern.append("[/]?"); return Pattern.compile(regexPattern.toString()); } 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(); @Override String toString(); }
Route { public static Pattern compile(String pattern, List<String> keywords) { StringBuilder regexPattern = new StringBuilder(); if (pattern.equals("/")) { regexPattern.append("/"); } else { final String[] segments = pattern.split("/"); for (String segment : segments) { if (!segment.equals("")) { if (keywordPattern.matcher(segment).matches()) { String keyword = segment.substring(1); if (keyword.indexOf("*") == 0) { keyword = keyword.substring(1); regexPattern.append("[/]?").append("(?<").append(keyword).append(">.*)"); } else { regexPattern.append("/").append("(?<").append(keyword).append(">[^/]*)"); } keywords.add(keyword); } else { regexPattern.append("/").append(segment); } } } } regexPattern.append("[/]?"); return Pattern.compile(regexPattern.toString()); } 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(); @Override String toString();  }