-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
ood-interview/file_search/filesearch/filesystem/File.java
Lines 27 to 41 in bce98e5
| switch (attributeName) { | |
| case SIZE -> { | |
| return size; | |
| } | |
| case OWNER -> { | |
| return owner; | |
| } | |
| case IS_DIRECTORY -> { | |
| return isDirectory; | |
| } | |
| case FILENAME -> { | |
| return filename; | |
| } | |
| } | |
| throw new IllegalArgumentException("invalid filter criteria type"); |
As -> is alread used in the switch block, it can be enhanced:
return switch (attributeName) {
case SIZE -> size;
case OWNER -> owner;
case IS_DIRECTORY -> isDirectory;
case FILENAME -> filename;
}This is better as you can skip the unnecessary throw at the end, as the switch branch is exhaustive.
Metadata
Metadata
Assignees
Labels
No labels