ResourceFileManager { static String createExtensionRegex(Set<String> fileExtensions) { StringBuilder validExtensions = new StringBuilder(); for (Iterator<String> it = fileExtensions.iterator(); it.hasNext(); ) { String extension = it.next(); if (it.hasNext()) validExtensions.append(extension).append("|"); else validExtensions.append(extension); } return ".*\\.(?i)(" + validExtensions + ")"; }  static Set<String> getResourcePaths(String path); static Set<String> getResourceFolders(String path); static boolean resourceExists(String location); static Set<String> getMatchingResources(String location);  }
@Test void canConstructRegexForFileExtensions() { Set<String> extensions = Collections .unmodifiableSet(Sets.newHashSet("jpg", "jpeg", "png")); String result = ResourceFileManager.createExtensionRegex(extensions); String expected = ".*\\.(?i)(jpg|png|jpeg)"; assert (expected.equals(result)); }