@Test public void test() { SplitterMatcher matcher = new SplitterMatcher('.'); String pattern = ".a.b"; assertTrue(matcher.match(pattern, ".a.b")); assertFalse(matcher.match(pattern, ".a.b.")); assertFalse(matcher.match(pattern, ".a.")); pattern = ".a.*"; assertTrue(matcher.match(pattern, ".a.b")); assertTrue(matcher.match(pattern, ".a.")); assertFalse(matcher.match(pattern, ".")); assertFalse(matcher.match(pattern, ".a.b.c")); pattern = ".a.b?c"; assertTrue(matcher.match(pattern, ".a.bac")); assertFalse(matcher.match(pattern, ".a.bc")); assertFalse(matcher.match(pattern, ".a.b")); assertFalse(matcher.match(pattern, ".a.bccc")); pattern = ".a.b*"; assertTrue(matcher.match(pattern, ".a.b")); assertTrue(matcher.match(pattern, ".a.b1")); assertTrue(matcher.match(pattern, ".a.bv1")); assertFalse(matcher.match(pattern, ".a.b1.c")); assertFalse(matcher.match(pattern, ".a.b.c")); assertFalse(matcher.match(pattern, ".a.c")); pattern = ".a.b**"; assertTrue(matcher.match(pattern, ".a.b")); assertTrue(matcher.match(pattern, ".a.b1")); assertTrue(matcher.match(pattern, ".a.bv1")); assertFalse(matcher.match(pattern, ".a.c")); assertTrue(matcher.match(pattern, ".a.b1.c")); assertTrue(matcher.match(pattern, ".a.b.c")); pattern = ".a.**.a"; assertTrue(matcher.match(pattern, ".a.a")); assertTrue(matcher.match(pattern, ".a.1.a")); }
public boolean match(String pattern, String path) { boolean fastFail = path == null || (path.length() > 0 && (path.charAt(0) == splitter) != (pattern.charAt(0) == splitter)); if (fastFail) { return false; } if (Strings.isPattern(pattern)) { return PATTERNS.computeIfAbsent(pattern, this::parsePattern).matcher(path).matches(); } return pattern.equals(path); }
SplitterMatcher { public boolean match(String pattern, String path) { boolean fastFail = path == null || (path.length() > 0 && (path.charAt(0) == splitter) != (pattern.charAt(0) == splitter)); if (fastFail) { return false; } if (Strings.isPattern(pattern)) { return PATTERNS.computeIfAbsent(pattern, this::parsePattern).matcher(path).matches(); } return pattern.equals(path); } }
SplitterMatcher { public boolean match(String pattern, String path) { boolean fastFail = path == null || (path.length() > 0 && (path.charAt(0) == splitter) != (pattern.charAt(0) == splitter)); if (fastFail) { return false; } if (Strings.isPattern(pattern)) { return PATTERNS.computeIfAbsent(pattern, this::parsePattern).matcher(path).matches(); } return pattern.equals(path); } SplitterMatcher(char splitter); }
SplitterMatcher { public boolean match(String pattern, String path) { boolean fastFail = path == null || (path.length() > 0 && (path.charAt(0) == splitter) != (pattern.charAt(0) == splitter)); if (fastFail) { return false; } if (Strings.isPattern(pattern)) { return PATTERNS.computeIfAbsent(pattern, this::parsePattern).matcher(path).matches(); } return pattern.equals(path); } SplitterMatcher(char splitter); boolean match(String pattern, String path); }
SplitterMatcher { public boolean match(String pattern, String path) { boolean fastFail = path == null || (path.length() > 0 && (path.charAt(0) == splitter) != (pattern.charAt(0) == splitter)); if (fastFail) { return false; } if (Strings.isPattern(pattern)) { return PATTERNS.computeIfAbsent(pattern, this::parsePattern).matcher(path).matches(); } return pattern.equals(path); } SplitterMatcher(char splitter); boolean match(String pattern, String path);  }