diff options
Diffstat (limited to 'component/src/main')
-rw-r--r-- | component/src/main/java/com/yahoo/component/Version.java | 16 |
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; |