Add equals and hashCode method for IceCandidate class.
Bug: webrtc:11072 Change-Id: I03568c3290a49466d0f459b1de8c89afaaf020ba Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158860 Commit-Queue: Honghai Zhang <honghaiz@webrtc.org> Reviewed-by: Alex Glaznev <glaznev@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29695}
This commit is contained in:
committed by
Commit Bot
parent
be43b7c4d7
commit
ad04327df8
@ -10,6 +10,8 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import org.webrtc.PeerConnection;
|
||||
|
||||
/**
|
||||
@ -56,4 +58,29 @@ public class IceCandidate {
|
||||
String getSdp() {
|
||||
return sdp;
|
||||
}
|
||||
|
||||
/** equals() checks sdpMid, sdpMLineIndex, and sdp for equality. */
|
||||
@Override
|
||||
public boolean equals(@Nullable Object object) {
|
||||
if (!(object instanceof IceCandidate)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IceCandidate that = (IceCandidate) object;
|
||||
return objectEquals(this.sdpMid, that.sdpMid) && this.sdpMLineIndex == that.sdpMLineIndex
|
||||
&& objectEquals(this.sdp, that.sdp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Object[] values = {sdpMid, sdpMLineIndex, sdp};
|
||||
return Arrays.hashCode(values);
|
||||
}
|
||||
|
||||
private static boolean objectEquals(Object o1, Object o2) {
|
||||
if (o1 == null) {
|
||||
return o2 == null;
|
||||
}
|
||||
return o1.equals(o2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user