mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 18:28:55 +07:00
[java-inspections] IDEA-324141 Use var for the inspection "Bulk 'Files.readAttributes()' call can be used"
PR#2508 Reviewed-by: Tagir Valeev <tagir.valeev@jetbrains.com> GitOrigin-RevId: c3914e71028831bcd72121e0f3070d4ed1fc01db
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b5322dba9c
commit
7ce127b0f9
@@ -0,0 +1,18 @@
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true-preview"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
class Foo {
|
||||
|
||||
private File file;
|
||||
|
||||
boolean printDirectory() {
|
||||
try {
|
||||
var basicFileAttributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
|
||||
return basicFileAttributes.isDirectory() && basicFileAttributes.isRegularFile();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
private File file;
|
||||
|
||||
boolean printDirectory() {
|
||||
try {
|
||||
return file.isDirec<caret>tory() && file.isFile();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user