Committed by
Gerrit Code Review
Refactor: Use descriptive methods when comparing Timestamps
Change-Id: I938f1db98c3d6868da73b5f3e8e01e7a787260c1
Showing
2 changed files
with
12 additions
and
2 deletions
... | @@ -191,9 +191,9 @@ public class IntentData { //FIXME need to make this "immutable" | ... | @@ -191,9 +191,9 @@ public class IntentData { //FIXME need to make this "immutable" |
191 | 191 | ||
192 | if (currentData == null) { | 192 | if (currentData == null) { |
193 | return true; | 193 | return true; |
194 | - } else if (currentData.version().compareTo(newData.version()) < 0) { | 194 | + } else if (currentData.version().isOlderThan(newData.version())) { |
195 | return true; | 195 | return true; |
196 | - } else if (currentData.version().compareTo(newData.version()) > 0) { | 196 | + } else if (currentData.version().isNewerThan(newData.version())) { |
197 | return false; | 197 | return false; |
198 | } | 198 | } |
199 | 199 | ... | ... |
... | @@ -40,4 +40,14 @@ public interface Timestamp extends Comparable<Timestamp> { | ... | @@ -40,4 +40,14 @@ public interface Timestamp extends Comparable<Timestamp> { |
40 | default boolean isNewerThan(Timestamp other) { | 40 | default boolean isNewerThan(Timestamp other) { |
41 | return this.compareTo(checkNotNull(other)) > 0; | 41 | return this.compareTo(checkNotNull(other)) > 0; |
42 | } | 42 | } |
43 | + | ||
44 | + /** | ||
45 | + * Tests if this timestamp is older than the specified timestamp. | ||
46 | + * | ||
47 | + * @param other timestamp to compare against | ||
48 | + * @return true if this instance is older | ||
49 | + */ | ||
50 | + default boolean isOlderThan(Timestamp other) { | ||
51 | + return this.compareTo(checkNotNull(other)) < 0; | ||
52 | + } | ||
43 | } | 53 | } | ... | ... |
-
Please register or login to post a comment