diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-08 21:09:55 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-08 21:37:51 +0200 |
| commit | 2266c5a6a22c027092bc93d5976fb3c0e6bd6187 (patch) | |
| tree | 0c414b07de355098e8e6d6075fe9d9d411b495c2 | |
| parent | ac22c8075ec35ffd938ee145a89bb3e1d84f12d5 (diff) | |
| download | cgeo-2266c5a6a22c027092bc93d5976fb3c0e6bd6187.zip cgeo-2266c5a6a22c027092bc93d5976fb3c0e6bd6187.tar.gz cgeo-2266c5a6a22c027092bc93d5976fb3c0e6bd6187.tar.bz2 | |
Work on #1367: cleanup cgCache.isEqualTo
- make method private
- argument cannot be null, this has been checked by the caller already
- do not use if (test) return true; else return false;
- use StringUtils.equalsIgnoreCase() when a field could be null
| -rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index 62f114f..b7f49e1 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -298,18 +298,10 @@ public class cgCache implements ICache { * @param other * @return true if both caches have the same content */ - public boolean isEqualTo(cgCache other) { - if (other == null) { - return false; - } - - if ( - // updated - // detailedUpdate - // visitedDate - detailed == other.detailed && - geocode.equalsIgnoreCase(other.geocode) && - name.equalsIgnoreCase(other.name) && + private boolean isEqualTo(final cgCache other) { + return detailed == other.detailed && + StringUtils.equalsIgnoreCase(geocode, other.geocode) && + StringUtils.equalsIgnoreCase(name, other.name) && cacheType == other.cacheType && size == other.size && found == other.found && @@ -317,25 +309,25 @@ public class cgCache implements ICache { premiumMembersOnly == other.premiumMembersOnly && difficulty == other.difficulty && terrain == other.terrain && - (coords != null ? coords.isEqualTo(other.coords) : coords == other.coords) && + (coords != null ? coords.isEqualTo(other.coords) : null == other.coords) && reliableLatLon == other.reliableLatLon && disabled == other.disabled && archived == other.archived && listId == other.listId && - owner.equalsIgnoreCase(other.owner) && - ownerReal.equalsIgnoreCase(other.ownerReal) && - (description != null ? description.equalsIgnoreCase(other.description) : null == other.description) && - (personalNote != null ? personalNote.equalsIgnoreCase(other.personalNote) : null == other.personalNote) && - shortdesc.equalsIgnoreCase(other.shortdesc) && - latlon.equalsIgnoreCase(other.latlon) && - location.equalsIgnoreCase(other.location) && + StringUtils.equalsIgnoreCase(owner, other.owner) && + StringUtils.equalsIgnoreCase(ownerReal, other.ownerReal) && + StringUtils.equalsIgnoreCase(description, other.description) && + StringUtils.equalsIgnoreCase(personalNote, other.personalNote) && + StringUtils.equalsIgnoreCase(shortdesc, other.shortdesc) && + StringUtils.equalsIgnoreCase(latlon, other.latlon) && + StringUtils.equalsIgnoreCase(location, other.location) && favorite == other.favorite && favoritePoints == other.favoritePoints && onWatchlist == other.onWatchlist && - (hidden != null ? hidden.compareTo(other.hidden) == 0 : hidden == other.hidden) && - guid.equalsIgnoreCase(other.guid) && - hint.equalsIgnoreCase(other.hint) && - cacheId.equalsIgnoreCase(other.cacheId) && + (hidden != null ? hidden.equals(other.hidden) : null == other.hidden) && + StringUtils.equalsIgnoreCase(guid, other.guid) && + StringUtils.equalsIgnoreCase(hint, other.hint) && + StringUtils.equalsIgnoreCase(cacheId, other.cacheId) && (direction != null ? direction.equals(other.direction) : null == other.direction) && (distance != null ? distance.equals(other.distance) : null == other.distance) && (elevation != null ? elevation.equals(other.elevation) : null == other.elevation) && @@ -351,10 +343,7 @@ public class cgCache implements ICache { inventory == other.inventory && logCounts == other.logCounts && logOffline == other.logOffline && - finalDefined == other.finalDefined) { - return true; - } - return false; + finalDefined == other.finalDefined; } public boolean hasTrackables() { |
