commit | 9eead3c59f67386e2e4b4b36613a6ec5c062cab5 | [log] [tgz] |
---|---|---|
author | Jordan Halterman <jordan@onlab.us> | Tue May 09 12:24:14 2017 -0700 |
committer | Thomas Vachuska <tom@onlab.us> | Wed May 10 21:41:02 2017 +0000 |
tree | e60b17167cd9c8accbacf9ee86d6b63ce833a73f | |
parent | 881e45009fc7dcbaad617449979e5b694c60e82d [diff] |
[ONOS-6424] Implement missing equals/hashCode methods in classes used in ResourceStore Change-Id: Idb55676a4232200e1eae5338618d76bb2ca9b836
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ContinuousResourceAllocation.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ContinuousResourceAllocation.java index c9f1071..03dc713 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ContinuousResourceAllocation.java +++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ContinuousResourceAllocation.java
@@ -22,6 +22,7 @@ import org.onosproject.net.resource.ResourceConsumerId; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -94,4 +95,26 @@ Stream.concat(nonMatched.stream(), matched.stream()) .collect(GuavaCollectors.toImmutableList())); } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + ContinuousResourceAllocation that = (ContinuousResourceAllocation) o; + + if (!original.equals(that.original)) { + return false; + } + return allocations.equals(that.allocations); + } + + @Override + public int hashCode() { + return Objects.hash(original, allocations); + } }
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EmptyDiscreteResources.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EmptyDiscreteResources.java index 55a0e94..d956334 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EmptyDiscreteResources.java +++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/EmptyDiscreteResources.java
@@ -63,6 +63,16 @@ } @Override + public int hashCode() { + return INSTANCE.hashCode(); + } + + @Override + public boolean equals(Object object) { + return object instanceof DiscreteResources && ((DiscreteResources) object).isEmpty(); + } + + @Override public String toString() { return MoreObjects.toStringHelper(this) .add("values", ImmutableSet.of())