From 27f4c59128fe8b5e4c84be8ebd38370b56705664 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <post@soeren-henning.de>
Date: Wed, 22 Jul 2020 12:08:24 +0200
Subject: [PATCH] Add equals/hachCode functions

---
 .../streamprocessing/JointRecordParents.java  | 22 +++++++++++++++++++
 .../uc2/streamprocessing/SensorParentKey.java | 20 +++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/uc2-application/src/main/java/theodolite/uc2/streamprocessing/JointRecordParents.java b/uc2-application/src/main/java/theodolite/uc2/streamprocessing/JointRecordParents.java
index 02b731858..71505ad30 100644
--- a/uc2-application/src/main/java/theodolite/uc2/streamprocessing/JointRecordParents.java
+++ b/uc2-application/src/main/java/theodolite/uc2/streamprocessing/JointRecordParents.java
@@ -1,5 +1,6 @@
 package theodolite.uc2.streamprocessing;
 
+import java.util.Objects;
 import java.util.Set;
 import titan.ccp.models.records.ActivePowerRecord;
 
@@ -26,6 +27,27 @@ public class JointRecordParents {
     return this.record;
   }
 
+  @Override
+  public String toString() {
+    return "{" + this.parents + ", " + this.record + "}";
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(this.parents, this.record);
+  }
 
+  @Override
+  public boolean equals(final Object obj) {
+    if (obj == this) {
+      return true;
+    }
+    if (obj instanceof JointRecordParents) {
+      final JointRecordParents other = (JointRecordParents) obj;
+      return Objects.equals(this.parents, other.parents)
+          && Objects.equals(this.record, other.record);
+    }
+    return false;
+  }
 
 }
diff --git a/uc2-application/src/main/java/theodolite/uc2/streamprocessing/SensorParentKey.java b/uc2-application/src/main/java/theodolite/uc2/streamprocessing/SensorParentKey.java
index d65c93034..a4fb5b339 100644
--- a/uc2-application/src/main/java/theodolite/uc2/streamprocessing/SensorParentKey.java
+++ b/uc2-application/src/main/java/theodolite/uc2/streamprocessing/SensorParentKey.java
@@ -1,5 +1,7 @@
 package theodolite.uc2.streamprocessing;
 
+import java.util.Objects;
+
 /**
  * A key consisting of the identifier of a sensor and an identifier of parent sensor.
  */
@@ -27,4 +29,22 @@ public class SensorParentKey {
     return "{" + this.sensorIdentifier + ", " + this.parentIdentifier + "}";
   }
 
+  @Override
+  public int hashCode() {
+    return Objects.hash(this.sensorIdentifier, this.parentIdentifier);
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+    if (obj == this) {
+      return true;
+    }
+    if (obj instanceof SensorParentKey) {
+      final SensorParentKey other = (SensorParentKey) obj;
+      return Objects.equals(this.sensorIdentifier, other.sensorIdentifier)
+          && Objects.equals(this.parentIdentifier, other.parentIdentifier);
+    }
+    return false;
+  }
+
 }
-- 
GitLab