Skip to content

Improve extract() method #5

@ntalbs

Description

@ntalbs

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions