Leverage basic Java 17 features (#451)

- Refactor code to use the following basic Java 17 features:
  - pattern matching for instanceof
  - @Serial annotation
  - switch expressions
  - enhanced switch statements
  - StringBuilder.isEmpty()
- Replace two switch statements with simpler if statements.
- Rename a few local variables.
This commit is contained in:
translatenix
2024-04-25 12:52:28 -07:00
committed by GitHub
parent 3ab9e4184e
commit a7c7e51180
142 changed files with 1333 additions and 1798 deletions

View File

@@ -111,10 +111,10 @@ public class ListSort {
// append `.length` to avoid rendering the list
new ReplRequest.Eval("sort", "nums.sortWith(cmp).length", false, false))
.get(0);
if (!(response instanceof ReplResponse.EvalSuccess)) {
if (!(response instanceof ReplResponse.EvalSuccess success)) {
throw new AssertionError(response);
}
return ((ReplResponse.EvalSuccess) response).getResult();
return success.getResult();
}
// note that this is an uneven comparison