<i18n dev> RFR: 8336847: Use pattern match switch in NumberFormat classes

Justin Lu jlu at openjdk.org
Tue Jul 23 18:36:31 UTC 2024


On Tue, 23 Jul 2024 18:04:54 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> src/java.base/share/classes/java/text/DecimalFormat.java line 1797:
>> 
>>> 1795:             case Long l -> digitList.set(isNegative, l, maxDigits);
>>> 1796:             case BigInteger bi -> digitList.set(isNegative, bi, maxDigits);
>>> 1797:             default -> {} // do nothing
>> 
>> default case could also be thrown `AssertionError` if preferred.
>
> Or a simple `assert` statement, as throwing an Error could change the behavior

Either of the 3 is fine with me. In this case, I think `AssertionError` is harmless, because AFAICT it is internally used by CompactNumberFormat only, and so throwing may prevent potential incorrect uses in the future.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20302#discussion_r1688523933


More information about the i18n-dev mailing list