It means that separate File.exists() check before File.isDirectory() check is redundant.
File file = new File(path);
try {
- if (file.exists()) {
- if (file.isDirectory()) {
- vec.add(new Dir(path));
- } else if (file.getName().endsWith("jrt-fs.jar")) { // TODO a bit crude...
+ if (file.isDirectory()) {
+ vec.add(new Dir(path));
+ } else if (file.exists()) {
+ if (file.getName().endsWith("jrt-fs.jar")) { // TODO a bit crude...
vec.add(new JImage());
} else {
vec.add(new Zip(new ZipFile(file)));
void checkSourceDirectory(File srcDir, String module) {
final String label = "source dir " + srcDir + " (module " + module + ")";
- assertTrue(label, (srcDir.exists() && srcDir.isDirectory()));
+ assertTrue(label, srcDir.isDirectory());
String license = getLicense(module);
// if (replacing) {
// if (replacing && true) {
if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) {
return true;
}
- if (checkClassFiles && f.exists() && f.isDirectory()) {
+ if (checkClassFiles && f.isDirectory()) {
// We should use here a list/set of directories we know have or have not changed - some kind of
// List<File> buildConfig.getClasspathEntriesWithChangedContents()
if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) {
return true;
}
- if (checkClassFiles && f.exists() && f.isDirectory()) {
+ if (checkClassFiles && f.isDirectory()) {
// We should use here a list/set of directories we know have or have not changed - some kind of
// List<File> buildConfig.getClasspathEntriesWithChangedContents()
File parent = argfile.getParentFile();
// Sanity check
- if (parent == null || !parent.exists() || !parent.isDirectory()) {
+ if (parent == null || !parent.isDirectory()) {
return;
}
* return true;
* }}, true);</code></pre>
* @param file root/starting point. If a file, the only one visited.
- * @param filter supplies boolean accept(File) method
+ * @param fileFilter supplies boolean accept(File) method
* @param userRecursion - if true, do accept() on dirs; else, recurse
* @return false if any fileFilter.accept(File) did.
* @throws IllegalArgumentException if file or fileFilter is null
*/
protected static boolean deleteDirectory(File dir) {
return ((null != dir)
- && dir.exists()
&& dir.isDirectory()
&& FileUtil.descendFileTree(dir, DELETE_FILES, false)
&& FileUtil.descendFileTree(dir, DELETE_DIRS, true)
protected static final FileFilter DELETE_DIRS = new FileFilter() {
public boolean accept(File file) {
return ((null != file) && file.isDirectory()
- && file.exists() && file.delete());
+ && file.delete());
}
};
protected static final FileFilter DELETE_FILES = new FileFilter() {