@Test(expected = IllegalArgumentException.class) public void testIdentifyClassFilesWithWrongInput() { Map<String, Object> parameters = Maps.newHashMap(); parameters.put("baseDir", TEST_CLASSES_DIR); Set<String> input = new HashSet<>(); input.add("**/*.class"); parameters.put("includes", input); FileNameUtil.identifyFiles(parameters); }
public static List<File> identifyFiles(Map parameters) { String baseDir = (String) parameters.get("baseDir"); if (Strings.isNullOrEmpty(baseDir) || !new File(baseDir).exists()) { return new ArrayList<>(); } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(baseDir); setIncludesExcludes(parameters.get("includes"), scanner::setIncludes); setIncludesExcludes(parameters.get("excludes"), scanner::setExcludes); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); return Arrays.stream(files) .map(filename -> new File(baseDir, filename)) .sorted(Comparator.comparing(File::getAbsolutePath)) .collect(Collectors.toList()); }
FileNameUtil { public static List<File> identifyFiles(Map parameters) { String baseDir = (String) parameters.get("baseDir"); if (Strings.isNullOrEmpty(baseDir) || !new File(baseDir).exists()) { return new ArrayList<>(); } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(baseDir); setIncludesExcludes(parameters.get("includes"), scanner::setIncludes); setIncludesExcludes(parameters.get("excludes"), scanner::setExcludes); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); return Arrays.stream(files) .map(filename -> new File(baseDir, filename)) .sorted(Comparator.comparing(File::getAbsolutePath)) .collect(Collectors.toList()); } }
FileNameUtil { public static List<File> identifyFiles(Map parameters) { String baseDir = (String) parameters.get("baseDir"); if (Strings.isNullOrEmpty(baseDir) || !new File(baseDir).exists()) { return new ArrayList<>(); } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(baseDir); setIncludesExcludes(parameters.get("includes"), scanner::setIncludes); setIncludesExcludes(parameters.get("excludes"), scanner::setExcludes); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); return Arrays.stream(files) .map(filename -> new File(baseDir, filename)) .sorted(Comparator.comparing(File::getAbsolutePath)) .collect(Collectors.toList()); } private  FileNameUtil(); }
FileNameUtil { public static List<File> identifyFiles(Map parameters) { String baseDir = (String) parameters.get("baseDir"); if (Strings.isNullOrEmpty(baseDir) || !new File(baseDir).exists()) { return new ArrayList<>(); } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(baseDir); setIncludesExcludes(parameters.get("includes"), scanner::setIncludes); setIncludesExcludes(parameters.get("excludes"), scanner::setExcludes); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); return Arrays.stream(files) .map(filename -> new File(baseDir, filename)) .sorted(Comparator.comparing(File::getAbsolutePath)) .collect(Collectors.toList()); } private  FileNameUtil(); static List<File> identifyFiles(Map parameters); static boolean isIncluded(String name, Map parameters); static boolean matches(String name, List<String> patterns, boolean defaultValue); static boolean matches(String name, String pattern); static String getParentPath(String fileName); static String getCanonicalPath(String path); }
FileNameUtil { public static List<File> identifyFiles(Map parameters) { String baseDir = (String) parameters.get("baseDir"); if (Strings.isNullOrEmpty(baseDir) || !new File(baseDir).exists()) { return new ArrayList<>(); } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir(baseDir); setIncludesExcludes(parameters.get("includes"), scanner::setIncludes); setIncludesExcludes(parameters.get("excludes"), scanner::setExcludes); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); return Arrays.stream(files) .map(filename -> new File(baseDir, filename)) .sorted(Comparator.comparing(File::getAbsolutePath)) .collect(Collectors.toList()); } private  FileNameUtil(); static List<File> identifyFiles(Map parameters); static boolean isIncluded(String name, Map parameters); static boolean matches(String name, List<String> patterns, boolean defaultValue); static boolean matches(String name, String pattern); static String getParentPath(String fileName); static String getCanonicalPath(String path);  }