<i18n dev> RFR: 8342863: Use pattern matching for instanceof in equals methods of wrapper classes

Joe Darcy darcy at openjdk.org
Wed Oct 23 15:40:09 UTC 2024


On Wed, 23 Oct 2024 02:14:49 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Noticed this refactoring opportunity while doing some other work in the area.
>
> src/java.base/share/classes/java/lang/Long.java line 1249:
> 
>> 1247:     public boolean equals(Object obj) {
>> 1248:         if (obj instanceof Long ell) {
>> 1249:             return value == ell.longValue();
> 
> Suggestion:
> 
>         if (obj instanceof Long l) {
>             return value == l.longValue();

In other place in the code, I've written out "ell" to avoid any confusion between lowercase "l" and a number "1", etc.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21652#discussion_r1813057470


More information about the i18n-dev mailing list