diff --git a/src/main/java/org/dataalgorithms/bonus/friendrecommendation/mapreduce/PairOfLongs.java b/src/main/java/org/dataalgorithms/bonus/friendrecommendation/mapreduce/PairOfLongs.java
index 1285aef7..861bce15 100644
--- a/src/main/java/org/dataalgorithms/bonus/friendrecommendation/mapreduce/PairOfLongs.java
+++ b/src/main/java/org/dataalgorithms/bonus/friendrecommendation/mapreduce/PairOfLongs.java
@@ -95,6 +95,10 @@ public void set(long left, long right) {
* otherwise
*/
public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ if (this.getClass() != obj.getClass())
+ return false;
PairOfLongs pair = (PairOfLongs) obj;
return left == pair.getLeft() && right == pair.getRight();
}
diff --git a/src/main/java/org/dataalgorithms/chap05/mapreduce/PairOfWords.java b/src/main/java/org/dataalgorithms/chap05/mapreduce/PairOfWords.java
index 103f5c28..7e960b41 100755
--- a/src/main/java/org/dataalgorithms/chap05/mapreduce/PairOfWords.java
+++ b/src/main/java/org/dataalgorithms/chap05/mapreduce/PairOfWords.java
@@ -146,6 +146,10 @@ public void set(String left, String right) {
* @return true
if obj
is equal to this object, false
otherwise
*/
public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ if (this.getClass() != obj.getClass())
+ return false;
PairOfWords pair = (PairOfWords) obj;
return leftElement.equals(pair.getLeftElement())
&& rightElement.equals(pair.getRightElement());