Refactor: Use descriptive methods when comparing Timestamps
Change-Id: I938f1db98c3d6868da73b5f3e8e01e7a787260c1
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
index 63ce928..b70e7cc 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentData.java
@@ -191,9 +191,9 @@
if (currentData == null) {
return true;
- } else if (currentData.version().compareTo(newData.version()) < 0) {
+ } else if (currentData.version().isOlderThan(newData.version())) {
return true;
- } else if (currentData.version().compareTo(newData.version()) > 0) {
+ } else if (currentData.version().isNewerThan(newData.version())) {
return false;
}
diff --git a/core/api/src/main/java/org/onosproject/store/Timestamp.java b/core/api/src/main/java/org/onosproject/store/Timestamp.java
index 1f15312..ddb9aa4 100644
--- a/core/api/src/main/java/org/onosproject/store/Timestamp.java
+++ b/core/api/src/main/java/org/onosproject/store/Timestamp.java
@@ -40,4 +40,14 @@
default boolean isNewerThan(Timestamp other) {
return this.compareTo(checkNotNull(other)) > 0;
}
+
+ /**
+ * Tests if this timestamp is older than the specified timestamp.
+ *
+ * @param other timestamp to compare against
+ * @return true if this instance is older
+ */
+ default boolean isOlderThan(Timestamp other) {
+ return this.compareTo(checkNotNull(other)) < 0;
+ }
}