Sho SHIMIZU
Committed by Gerrit Code Review

Refactor: Use descriptive methods when comparing Timestamps

Change-Id: I938f1db98c3d6868da73b5f3e8e01e7a787260c1
......@@ -191,9 +191,9 @@ public class IntentData { //FIXME need to make this "immutable"
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;
}
......
......@@ -40,4 +40,14 @@ public interface Timestamp extends Comparable<Timestamp> {
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;
}
}
......