8267670: Update java.io, java.math, and java.text to use switch expressions

Reviewed-by: darcy, chegar, naoto, iris, dfuchs, lancea, vtewari
This commit is contained in:
Patrick Concannon 2021-06-01 10:14:56 +00:00
parent f5634fe39d
commit 4eb216824f
11 changed files with 161 additions and 349 deletions

View file

@ -4706,19 +4706,13 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
else { // half-way
assert cmpFracHalf == 0;
switch(roundingMode) {
case ROUND_HALF_DOWN:
return false;
return switch (roundingMode) {
case ROUND_HALF_DOWN -> false;
case ROUND_HALF_UP -> true;
case ROUND_HALF_EVEN -> oddQuot;
case ROUND_HALF_UP:
return true;
case ROUND_HALF_EVEN:
return oddQuot;
default:
throw new AssertionError("Unexpected rounding mode" + roundingMode);
}
default -> throw new AssertionError("Unexpected rounding mode" + roundingMode);
};
}
}
}