@Test public void byWildcardFilename_fails_if_matches_multiple_files() throws IOException { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Multiple files match [sonar-foo-plugin-*.jar] in directory"); File dir = temp.newFolder(); FileUtils.touch(new File(dir, "sonar-foo-plugin-0.1-SNAPSHOT.jar")); FileUtils.touch(new File(dir, "sonar-foo-plugin-0.2-SNAPSHOT.jar")); FileLocation.byWildcardFilename(dir, "sonar-foo-plugin-*.jar"); }
public static FileLocation byWildcardFilename(File directory, String wildcardFilename) { if (!directory.exists()) { throw new IllegalStateException(format("Directory [%s] does not exist", directory)); } WildcardFileFilter filter = new WildcardFileFilter(wildcardFilename, IOCase.SENSITIVE); Collection<File> files = new ArrayList<>(FileUtils.listFiles(directory, filter, null)); return getOnlyFile(directory, wildcardFilename, files); }
FileLocation implements Location { public static FileLocation byWildcardFilename(File directory, String wildcardFilename) { if (!directory.exists()) { throw new IllegalStateException(format("Directory [%s] does not exist", directory)); } WildcardFileFilter filter = new WildcardFileFilter(wildcardFilename, IOCase.SENSITIVE); Collection<File> files = new ArrayList<>(FileUtils.listFiles(directory, filter, null)); return getOnlyFile(directory, wildcardFilename, files); } }
FileLocation implements Location { public static FileLocation byWildcardFilename(File directory, String wildcardFilename) { if (!directory.exists()) { throw new IllegalStateException(format("Directory [%s] does not exist", directory)); } WildcardFileFilter filter = new WildcardFileFilter(wildcardFilename, IOCase.SENSITIVE); Collection<File> files = new ArrayList<>(FileUtils.listFiles(directory, filter, null)); return getOnlyFile(directory, wildcardFilename, files); } private  FileLocation(File file); }
FileLocation implements Location { public static FileLocation byWildcardFilename(File directory, String wildcardFilename) { if (!directory.exists()) { throw new IllegalStateException(format("Directory [%s] does not exist", directory)); } WildcardFileFilter filter = new WildcardFileFilter(wildcardFilename, IOCase.SENSITIVE); Collection<File> files = new ArrayList<>(FileUtils.listFiles(directory, filter, null)); return getOnlyFile(directory, wildcardFilename, files); } private  FileLocation(File file); static FileLocation of(File file); static FileLocation of(String path); static FileLocation of(URL url); static ResourceLocation ofClasspath(String pathStartingWithSlash); static FileLocation byWildcardFilename(File directory, String wildcardFilename); static FileLocation byWildcardMavenFilename(File directory, String wildcardFilename); @Deprecated static FileLocation ofShared(String relativePath); File getFile(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
FileLocation implements Location { public static FileLocation byWildcardFilename(File directory, String wildcardFilename) { if (!directory.exists()) { throw new IllegalStateException(format("Directory [%s] does not exist", directory)); } WildcardFileFilter filter = new WildcardFileFilter(wildcardFilename, IOCase.SENSITIVE); Collection<File> files = new ArrayList<>(FileUtils.listFiles(directory, filter, null)); return getOnlyFile(directory, wildcardFilename, files); } private  FileLocation(File file); static FileLocation of(File file); static FileLocation of(String path); static FileLocation of(URL url); static ResourceLocation ofClasspath(String pathStartingWithSlash); static FileLocation byWildcardFilename(File directory, String wildcardFilename); static FileLocation byWildcardMavenFilename(File directory, String wildcardFilename); @Deprecated static FileLocation ofShared(String relativePath); File getFile(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }