mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8226831: Use Objects.equals() when appropriate
Reviewed-by: rriggs, bpb
This commit is contained in:
parent
99bf89c581
commit
3ed845784d
7 changed files with 26 additions and 31 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,6 +25,8 @@
|
|||
|
||||
package java.net;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class represents a Network Interface address. In short it's an
|
||||
* IP address, a subnet mask and a broadcast address when the address is
|
||||
|
@ -99,17 +101,17 @@ public class InterfaceAddress {
|
|||
* @see java.net.InterfaceAddress#hashCode()
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof InterfaceAddress)) {
|
||||
return false;
|
||||
if (obj instanceof InterfaceAddress) {
|
||||
InterfaceAddress cmp = (InterfaceAddress) obj;
|
||||
|
||||
if (Objects.equals(address, cmp.address) &&
|
||||
Objects.equals(broadcast, cmp.broadcast) &&
|
||||
maskLength == cmp.maskLength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
InterfaceAddress cmp = (InterfaceAddress) obj;
|
||||
if ( !(address == null ? cmp.address == null : address.equals(cmp.address)) )
|
||||
return false;
|
||||
if ( !(broadcast == null ? cmp.broadcast == null : broadcast.equals(cmp.broadcast)) )
|
||||
return false;
|
||||
if (maskLength != cmp.maskLength)
|
||||
return false;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.io.InputStream;
|
|||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Objects;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
import sun.net.www.ParseUtil;
|
||||
|
||||
|
@ -343,10 +344,7 @@ public abstract class URLStreamHandler {
|
|||
* @since 1.3
|
||||
*/
|
||||
protected boolean equals(URL u1, URL u2) {
|
||||
String ref1 = u1.getRef();
|
||||
String ref2 = u2.getRef();
|
||||
return (ref1 == ref2 || (ref1 != null && ref1.equals(ref2))) &&
|
||||
sameFile(u1, u2);
|
||||
return Objects.equals(u1.getRef(), u2.getRef()) && sameFile(u1, u2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue