Skip to content

Improve extract() method #5

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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