Skip to content

Commit

Permalink
Fix for #93 null exeption in Region.equals
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtree1 committed Nov 14, 2014
1 parent f6eb8f1 commit 5931845
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/android/com/radiusnetworks/ibeacon/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,30 @@ protected Region() {

@Override
public int hashCode() {
return (this.uniqueId + this.proximityUuid + this.major + this.minor).hashCode();
String hashString = this.uniqueId + this.proximityUuid;
if (this.major != null)
hashString = hashString.concat(this.major.toString());
if (this.minor != null)
hashString = hashString.concat(this.minor.toString());
return hashString.hashCode();
}

public boolean equals(Object other) {
if (other instanceof Region) {
Region r = (Region) other;
return r.uniqueId.equals(this.uniqueId) &&
r.proximityUuid.equals(this.proximityUuid) &&
r.major.equals(this.major) &&
r.minor.equals(this.minor);
if (!r.uniqueId.equals(this.uniqueId))
return false;

if (!r.proximityUuid.equals(this.proximityUuid))
return false;

if (r.major != null && !r.major.equals(this.major))
return false;

if (r.minor != null && !r.minor.equals(this.minor))
return false;

return true;
}
return false;
}
Expand Down

0 comments on commit 5931845

Please sign in to comment.