From 455b6e79f036b096ebb1d21c34443a853aa90864 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 2 Aug 2017 07:00:34 -0700 Subject: [PATCH] use TextUtils.equals in new equals() overrides --- .../eehouse/android/xw4/NetLaunchInfo.java | 25 +++++++------------ .../eehouse/android/xw4/jni/CurGameInfo.java | 7 +++--- .../eehouse/android/xw4/jni/GameSummary.java | 12 +++------ .../eehouse/android/xw4/jni/LocalPlayer.java | 10 +++----- 4 files changed, 20 insertions(+), 34 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java index 7fffef51c..b5102fe7e 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/NetLaunchInfo.java @@ -25,6 +25,7 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; +import android.text.TextUtils; import java.io.InputStream; import java.io.Serializable; @@ -328,24 +329,17 @@ public class NetLaunchInfo implements Serializable { boolean result = null != obj && obj instanceof NetLaunchInfo; if ( result ) { other = (NetLaunchInfo)obj; - result = ((null == gameName) ? (null == other.gameName) - : gameName.equals(other.gameName)) - && ((null == dict) ? (null == other.dict) - : dict.equals(other.dict)) + result = TextUtils.equals( gameName, other.gameName ) + && TextUtils.equals( dict, other.dict ) && lang == other.lang && forceChannel == other.forceChannel && nPlayersT == other.nPlayersT && nPlayersH == other.nPlayersH - && ((null == room) ? (null == other.room) - : room.equals(other.room)) - && ((null == btName) ? (null == other.btName) - : btName.equals(other.btName)) - && ((null == btAddress) ? (null == other.btAddress) - : btAddress.equals(other.btAddress)) - && ((null == p2pMacAddress) ? (null == other.p2pMacAddress) - : p2pMacAddress.equals(other.p2pMacAddress)) - && ((null == phone) ? (null == other.phone) - : phone.equals(other.phone)) + && TextUtils.equals( room, other.room ) + && TextUtils.equals( btName, other.btName ) + && TextUtils.equals( btAddress, other.btAddress ) + && TextUtils.equals( p2pMacAddress, other.p2pMacAddress ) + && TextUtils.equals( phone, other.phone ) && isGSM == other. isGSM && osVers == other.osVers && _conTypes == other._conTypes @@ -353,8 +347,7 @@ public class NetLaunchInfo implements Serializable { && ((null == m_addrs ? (null == other.m_addrs) : m_addrs.equals(other.m_addrs))) && m_valid == other.m_valid - && ((null == inviteID ? (null == other.inviteID) - : inviteID.equals(other.inviteID))) + && TextUtils.equals( inviteID, other.inviteID ) ; } return result; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CurGameInfo.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CurGameInfo.java index 2ca019ad4..88c6ec97b 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CurGameInfo.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CurGameInfo.java @@ -21,6 +21,7 @@ package org.eehouse.android.xw4.jni; import android.content.Context; +import android.text.TextUtils; import java.io.Serializable; import java.util.Arrays; @@ -294,14 +295,12 @@ public class CurGameInfo implements Serializable { && allowHintRect == other.allowHintRect && m_smartness == other.m_smartness && Arrays.deepEquals( players, other.players ) - && ((null == dictName) ? (null == other.dictName) - : dictName.equals(other.dictName)) + && TextUtils.equals( dictName, other.dictName ) && ((null == serverRole) ? (null == other.serverRole) : serverRole.equals(other.serverRole)) && ((null == phoniesAction) ? (null == other.phoniesAction) : phoniesAction.equals(other.phoniesAction)) - && ((null == m_name) ? (null == other.m_name) - : m_name.equals(other.m_name)) + && TextUtils.equals( m_name, other.m_name ) ; } } else { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java index 4a6b54334..654661e79 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/GameSummary.java @@ -125,22 +125,18 @@ public class GameSummary implements Serializable { && Arrays.equals( m_players, other.m_players ) && ((null == conTypes) ? (null == other.conTypes) : conTypes.equals(other.conTypes)) - && ((null == roomName) ? (null == other.roomName) - : roomName.equals(other.roomName)) - && ((null == relayID) ? (null == other.relayID) - : relayID.equals(other.relayID)) + && TextUtils.equals( roomName, other.roomName ) + && TextUtils.equals( relayID, other.relayID ) && Arrays.equals( remoteDevs, other.remoteDevs ) && ((null == serverRole) ? (null == other.serverRole) : serverRole.equals(other.serverRole)) && ((null == m_giFlags) ? (null == other.m_giFlags) : m_giFlags.equals(other.m_giFlags)) - && ((null == m_playersSummary) ? (null == other.m_playersSummary) - : m_playersSummary.equals(other.m_playersSummary)) + && TextUtils.equals( m_playersSummary, other.m_playersSummary ) && ((null == m_gi) ? (null == other.m_gi) : m_gi.equals(other.m_gi)) && Arrays.equals( m_remotePhones, other.m_remotePhones ) - && ((null == m_extras) ? (null == other.m_extras) - : m_extras.equals(other.m_extras)) + && TextUtils.equals( m_extras, other.m_extras ) ; } } else { diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/LocalPlayer.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/LocalPlayer.java index e6d356148..0a9109857 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/LocalPlayer.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/LocalPlayer.java @@ -21,6 +21,7 @@ package org.eehouse.android.xw4.jni; import android.content.Context; +import android.text.TextUtils; import java.io.Serializable; @@ -73,12 +74,9 @@ public class LocalPlayer implements Serializable { result = secondsUsed == other.secondsUsed && robotIQ == other.robotIQ && isLocal == other.isLocal - && ((null == name) ? (null == other.name) - : name.equals(other.name)) - && ((null == password) ? (null == other.password) - : password.equals(other.password)) - && ((null == dictName) ? (null == other.dictName) - : dictName.equals(other.dictName)) + && TextUtils.equals( name, other.name ) + && TextUtils.equals( password, other.password ) + && TextUtils.equals( dictName, other.dictName ) ; } } else {