@Test void shouldSplitGlob() { assertEquals(Arrays.asList("foo", "*.bar"), Arrays.asList(Resources.globRoot("foo*.bar"), Arrays.asList(Resources.globRoot("**/*.bar"))); }
@VisibleForTesting static String[] globRoot(String glob) { int length = glob.length(); int j = 0; for (int i = 0; i < length; ++i) { char c = glob.charAt(i); switch (c) { case '/': j = i; break; case '\\': i++; if (i >= length) { throw new PatternSyntaxException("Invalid escape character at end of glob pattern", glob, length - 1); } break; case '*': case '?': case '[': case '{': if (i == 0) { return new String[] {"", glob}; } else { return new String[] {unescape(glob.substring(0, j)), glob.substring(j + 1)}; } default: } } return new String[] {unescape(glob)}; }
Resources { @VisibleForTesting static String[] globRoot(String glob) { int length = glob.length(); int j = 0; for (int i = 0; i < length; ++i) { char c = glob.charAt(i); switch (c) { case '/': j = i; break; case '\\': i++; if (i >= length) { throw new PatternSyntaxException("Invalid escape character at end of glob pattern", glob, length - 1); } break; case '*': case '?': case '[': case '{': if (i == 0) { return new String[] {"", glob}; } else { return new String[] {unescape(glob.substring(0, j)), glob.substring(j + 1)}; } default: } } return new String[] {unescape(glob)}; } }
Resources { @VisibleForTesting static String[] globRoot(String glob) { int length = glob.length(); int j = 0; for (int i = 0; i < length; ++i) { char c = glob.charAt(i); switch (c) { case '/': j = i; break; case '\\': i++; if (i >= length) { throw new PatternSyntaxException("Invalid escape character at end of glob pattern", glob, length - 1); } break; case '*': case '?': case '[': case '{': if (i == 0) { return new String[] {"", glob}; } else { return new String[] {unescape(glob.substring(0, j)), glob.substring(j + 1)}; } default: } } return new String[] {unescape(glob)}; } private  Resources(); }
Resources { @VisibleForTesting static String[] globRoot(String glob) { int length = glob.length(); int j = 0; for (int i = 0; i < length; ++i) { char c = glob.charAt(i); switch (c) { case '/': j = i; break; case '\\': i++; if (i >= length) { throw new PatternSyntaxException("Invalid escape character at end of glob pattern", glob, length - 1); } break; case '*': case '?': case '[': case '{': if (i == 0) { return new String[] {"", glob}; } else { return new String[] {unescape(glob.substring(0, j)), glob.substring(j + 1)}; } default: } } return new String[] {unescape(glob)}; } private  Resources(); @MustBeClosed static Stream<URL> find(String glob); @MustBeClosed @SuppressWarnings("MustBeClosedChecker") static Stream<URL> find(@Nullable ClassLoader classLoader, String glob); }
Resources { @VisibleForTesting static String[] globRoot(String glob) { int length = glob.length(); int j = 0; for (int i = 0; i < length; ++i) { char c = glob.charAt(i); switch (c) { case '/': j = i; break; case '\\': i++; if (i >= length) { throw new PatternSyntaxException("Invalid escape character at end of glob pattern", glob, length - 1); } break; case '*': case '?': case '[': case '{': if (i == 0) { return new String[] {"", glob}; } else { return new String[] {unescape(glob.substring(0, j)), glob.substring(j + 1)}; } default: } } return new String[] {unescape(glob)}; } private  Resources(); @MustBeClosed static Stream<URL> find(String glob); @MustBeClosed @SuppressWarnings("MustBeClosedChecker") static Stream<URL> find(@Nullable ClassLoader classLoader, String glob);  }