<i18n dev> RFR: 8268469: Update java.time to use switch expressions
Stephen Colebourne
scolebourne at openjdk.java.net
Wed Jun 9 22:20:13 UTC 2021
On Wed, 9 Jun 2021 15:41:59 GMT, Patrick Concannon <pconcannon at openjdk.org> wrote:
> Hi,
>
> Could someone please review my code for updating the code in the `java.time` packages to make use of the switch expressions?
>
> Kind regards,
> Patrick
My biggest comment is the spaces used to align, which I strongly object to. I agree with @dfuch comments too.
src/java.base/share/classes/java/time/LocalDate.java line 608:
> 606: if (chronoField.isDateBased()) {
> 607: return switch (chronoField) {
> 608: case DAY_OF_MONTH -> ValueRange.of(1, lengthOfMonth());
For the record, I hate code that is aligned like this. It makes refactoring much more noisy, as the author has to readjust all the associated lines. I also don't believe it is within the spirit of Java's traditional coding guidelines.
src/java.base/share/classes/java/time/chrono/ThaiBuddhistDate.java line 331:
> 329: yield with(isoDate.withYear(nvalue - YEARS_DIFFERENCE));
> 330: }
> 331: case ERA -> with(isoDate.withYear((1 - getProlepticYear()) - YEARS_DIFFERENCE));
`checkValidIntValue` performs validation, so removing it has changed the behavoiur
src/java.base/share/classes/java/time/format/SignStyle.java line 129:
> 127: // valid if negative or (positive and lenient)
> 128: case 0 -> !positive || !strict;// NORMAL
> 129: case 1, 4 -> true; // ALWAYS, EXCEEDS_PAD
Extra space before `4`
-------------
PR: https://git.openjdk.java.net/jdk/pull/4433
More information about the i18n-dev
mailing list