diff options
author | gjoranv <gv@verizonmedia.com> | 2021-10-04 12:17:56 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2021-10-04 12:18:46 +0200 |
commit | 58db7dade792660dc8c55fd753a797678a15ad34 (patch) | |
tree | 0edb00cf4adfbd78d049d65e0cfc1104885f6346 /hosted-zone-api/src | |
parent | 3f68eb7eb2f03020bed40f328294a0c9300fa17e (diff) |
Add equals and hashCode for Cluster.
Diffstat (limited to 'hosted-zone-api/src')
-rw-r--r-- | hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java index 5db68b9d5b3..dba0e3f30bc 100644 --- a/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java +++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/Cluster.java @@ -2,6 +2,7 @@ package ai.vespa.cloud; import java.util.Collections; import java.util.List; +import java.util.Objects; /** * The properties of a cluster of nodes. @@ -14,6 +15,7 @@ public class Cluster { private final List<Integer> indices; public Cluster(int size, List<Integer> indices) { + Objects.requireNonNull(indices, "Indices cannot be null!"); this.size = size; this.indices = Collections.unmodifiableList(indices); } @@ -26,4 +28,18 @@ public class Cluster { return indices; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Cluster cluster = (Cluster) o; + return size == cluster.size && + indices.equals(cluster.indices); + } + + @Override + public int hashCode() { + return Objects.hash(size, indices); + } + } |