Fix weird usage of Comparable
Change-Id: I03b7ebf80f419f2e09cc1c99d02b23cb0cdef6b3
diff --git a/apps/imr/app/src/main/java/org/onosproject/imr/IntentMonitorAndRerouteManager.java b/apps/imr/app/src/main/java/org/onosproject/imr/IntentMonitorAndRerouteManager.java
index 3ab49aa..9b5d070 100644
--- a/apps/imr/app/src/main/java/org/onosproject/imr/IntentMonitorAndRerouteManager.java
+++ b/apps/imr/app/src/main/java/org/onosproject/imr/IntentMonitorAndRerouteManager.java
@@ -65,6 +65,7 @@
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -303,7 +304,7 @@
// TODO: now we manage only the unsplittable routing
Path currentPath = route.paths()
.stream()
- .max(Path::compareTo)
+ .max(Comparator.comparing(Path::weight))
.get();
// Check if the last and first element of the path are HostId
@@ -437,6 +438,7 @@
return path;
}
+ @Override
public Map<ApplicationId, Map<Key, Pair<Set<ElementId>, Set<ElementId>>>> getMonitoredIntents() {
Map<ApplicationId, Map<Key, Pair<Set<ElementId>, Set<ElementId>>>> currentMonitoredIntents
= new ConcurrentHashMap<>();
@@ -452,6 +454,7 @@
return currentMonitoredIntents;
}
+ @Override
public Map<ApplicationId, Map<Key, Pair<Set<ElementId>, Set<ElementId>>>> getMonitoredIntents(
ApplicationId appId) {
Map<ApplicationId, Map<Key, Pair<Set<ElementId>, Set<ElementId>>>> currentMonitoredIntents
diff --git a/apps/imr/app/src/main/java/org/onosproject/imr/data/Path.java b/apps/imr/app/src/main/java/org/onosproject/imr/data/Path.java
index 97de631..b14d365 100644
--- a/apps/imr/app/src/main/java/org/onosproject/imr/data/Path.java
+++ b/apps/imr/app/src/main/java/org/onosproject/imr/data/Path.java
@@ -30,7 +30,7 @@
* Representation of a path in terms of list of elements that it has to traverse
* and weight.
*/
-public class Path implements Comparable {
+public class Path {
private List<ElementId> path;
private float weight;
@@ -76,21 +76,4 @@
.add("Path", this.path())
.toString();
}
-
- /**
- * Compare two paths in terms of weight.
- * @param o Object to compare
- * @return the comparison result
- */
- @Override
- public int compareTo(Object o) {
- Path s = (Path) o;
- if (this.weight < s.weight) {
- return -1;
- }
- if (this.weight > s.weight) {
- return 1;
- }
- return 0;
- }
}