aboutsummaryrefslogtreecommitdiffstats
path: root/component/src/main/java/com/yahoo/component
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-05-10 15:55:04 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2017-05-10 15:55:04 +0200
commitdf46d7d7fdf89868036dc6e2158737106fb91796 (patch)
treeb6b582e3c6933e859da2626fbdb544fe1e2d5b4b /component/src/main/java/com/yahoo/component
parent238389de531bf219aacfddee0e54f21ae1fd3033 (diff)
Add comparison methods for readability
Diffstat (limited to 'component/src/main/java/com/yahoo/component')
-rw-r--r--component/src/main/java/com/yahoo/component/Version.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/component/src/main/java/com/yahoo/component/Version.java b/component/src/main/java/com/yahoo/component/Version.java
index 8ef540c2ae7..53931406bb0 100644
--- a/component/src/main/java/com/yahoo/component/Version.java
+++ b/component/src/main/java/com/yahoo/component/Version.java
@@ -360,10 +360,20 @@ public final class Version implements Comparable<Version> {
return getQualifier().compareTo(other.getQualifier());
}
+
+ /** Returns whether this version number (ignoring qualifier) is strictly lower than the given version */
+ public boolean isBefore(Version other) {
+ if (this.major == other.major && this.minor == other.minor) return this.micro < other.micro;
+ if (this.major == other.major) return this.minor < other.minor;
+ return this.major < other.major;
+ }
- /**
- * Creates a version specification that only matches this version.
- */
+ /** Returns whether this version number (ignoring qualifier) is strictly higher than the given version */
+ public boolean isAfter(Version other) {
+ return ! this.isBefore(other) && ! this.equals(other);
+ }
+
+ /** Creates a version specification that only matches this version */
public VersionSpecification toSpecification() {
if (this == emptyVersion)
return VersionSpecification.emptyVersionSpecification;