summaryrefslogtreecommitdiff
path: root/directory/src/main
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-27 10:31:06 +0200
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-27 10:31:06 +0200
commita40161ac665ce982518d8ceea6f6bc6fede10651 (patch)
tree3cd707cc16e8e39588b4053b7cb4e538484beb41 /directory/src/main
parente340a4b120eaf0d490b183c1227bce0eb5b32495 (diff)
Fix NullPointerException.
Support null valiues in NetworkEntry.
Diffstat (limited to 'directory/src/main')
-rw-r--r--directory/src/main/java/com/orbekk/same/directory/NetworkEntry.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/directory/src/main/java/com/orbekk/same/directory/NetworkEntry.java b/directory/src/main/java/com/orbekk/same/directory/NetworkEntry.java
index cac21cc..8f06cce 100644
--- a/directory/src/main/java/com/orbekk/same/directory/NetworkEntry.java
+++ b/directory/src/main/java/com/orbekk/same/directory/NetworkEntry.java
@@ -21,10 +21,18 @@ public class NetworkEntry {
@Override
public boolean equals(Object other) {
if (other instanceof NetworkEntry) {
- NetworkEntry otherEntry = (NetworkEntry)other;
- return networkName.equals(otherEntry.networkName) &&
- masterUrl.equals(otherEntry.masterUrl);
+ NetworkEntry o = (NetworkEntry)other;
+ return stringEquals(networkName, o.networkName) &&
+ stringEquals(masterUrl, o.masterUrl);
}
return false;
}
+
+ private boolean stringEquals(String s1, String s2) {
+ if (s1 == null) {
+ return s2 == null;
+ } else {
+ return s1.equals(s2);
+ }
+ }
}