WildcardMatcher { public static boolean matchPath(String path, String pattern) { List<String> pathElements = PATH_SPLITTER.splitToList(path); List<String> patternElements = PATH_SPLITTER.splitToList(pattern); return matchTokens(pathElements.toArray(new String[0]), patternElements.toArray(new String[0])); }  static boolean match(CharSequence string, CharSequence pattern); static int matchOne(String src, String... patterns); static int matchPathOne(String platformDependentPath, String... patterns); static boolean matchPath(String path, String pattern);  }
@Test public void matchPath() { assertThat(WildcardMatcher.matchPath("/a/b/dd", "**")).isTrue(); assertThat(WildcardMatcher.matchPath("/a/b/dd", "**/dd")).isTrue(); assertThat(WildcardMatcher.matchPath("/a/b/c/dd", "/add")).isTrue(); assertThat(WildcardMatcher.matchPath("/a/b/dd", "/ad?")).isTrue(); assertThat(WildcardMatcher.matchPath("/a/b/ddxxa", "/add")).isTrue(); assertThat(WildcardMatcher.matchPath("/a/b/c/dd", "/add")).isFalse(); assertThat(WildcardMatcher.matchPath("/a/b/c/dd", "/add", "**/dd" })).isEqualTo(1); assertThat(WildcardMatcher.matchPathOne("/a/b/c/dd", new String[] { "/add", "**/dd" })).isEqualTo(0); assertThat(WildcardMatcher.matchPathOne("/a/b/c/dd", new String[] { "/b/d", "/a/cdd", "**\\dd" })).isEqualTo(1); assertThat(WildcardMatcher.matchPathOne("\\a\\b\\c\\dd", new String[] { "\\a\\**\\dd", "**\\dd" })) .isEqualTo(0); assertThat(WildcardMatcher.matchPathOne("\\a\\b\\c\\dd", new String[] { "/b/d", "/a/cdd", "**/dd" })).isEqualTo(1); assertThat(WildcardMatcher.matchPathOne("/a/b/c/dd", new String[] { "/add", "**/dd" })).isEqualTo(0); assertThat(WildcardMatcher.matchPathOne("/a/b/c/dd", new String[] { "/b/d", "/a/c/*" })).isEqualTo(-1); }