<i18n dev> RFR: 8268469: Update java.time to use switch expressions [v3]

Stephen Colebourne scolebourne at openjdk.java.net
Wed Jun 16 16:46:41 UTC 2021


On Wed, 16 Jun 2021 11:11:30 GMT, Chris Hegarty <chegar at openjdk.org> wrote:

>> src/java.base/share/classes/java/time/Month.java line 480:
>> 
>>> 478:         int leap = leapYear ? 1 : 0;
>>> 479:         return switch (this) {
>>> 480:             case JANUARY   -> 1;
>> 
>> Unnecessary alignment
>
> The vertical alignment improves readability in these short-line cases. Removing the spaces before the arrows will make it a little harder to discern the difference between the cases.

It is your codebase, not mine, so it is up to you. Aligning things by column is generally frowned on in most style guides because it handles refactoring poorly, resulting in lots of needless change (or people forgetting to realign things - I had to deal with a rogue aligned Javadoc signature today in a PR where exactly that had happened). I also don't see how you write a style guide rule for when these should be aligned and when they should not.

Anyway, this PR isn't really the right place for this discussion - I'm not blocking the PR on this basis (and I'm not an official Reviewer anyway).

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

PR: https://git.openjdk.java.net/jdk/pull/4433


More information about the i18n-dev mailing list