RFR: 8263233: Update java.net and java.nio to use instanceof pattern variable [v2]
Patrick Concannon
pconcannon at openjdk.java.net
Tue Mar 9 18:17:11 UTC 2021
On Tue, 9 Mar 2021 13:01:10 GMT, Michael McMahon <michaelm at openjdk.org> wrote:
>> src/java.base/share/classes/java/net/InterfaceAddress.java line 107:
>>
>>> 105:
>>> 106: if (Objects.equals(address, cmp.address) &&
>>> 107: Objects.equals(broadcast, cmp.broadcast) &&
>>
>> This could be simplified to:
>>
>> public boolean equals(Object obj) {
>> if (obj instanceof InterfaceAddress cmp
>> && Objects.equals(address, cmp.address)
>> && Objects.equals(broadcast, cmp.broadcast)
>> && maskLength == cmp.maskLength) {
>> return true;
>> }
>> return false;
>> }
>
> or go one step further and replace the if statement just with the boolean expression.
Replaced the if statement with boolean expression as suggested. See eca9095
-------------
PR: https://git.openjdk.java.net/jdk/pull/2890
More information about the net-dev
mailing list