diff options
Diffstat (limited to 'api/src/main/java/org/semver')
-rwxr-xr-x | api/src/main/java/org/semver/Delta.java | 4 | ||||
-rwxr-xr-x | api/src/main/java/org/semver/Version.java | 27 |
2 files changed, 18 insertions, 13 deletions
diff --git a/api/src/main/java/org/semver/Delta.java b/api/src/main/java/org/semver/Delta.java index e856bb2..ebb6b57 100755 --- a/api/src/main/java/org/semver/Delta.java +++ b/api/src/main/java/org/semver/Delta.java @@ -213,7 +213,7 @@ public final class Delta { if (current == null) { throw new IllegalArgumentException("null current"); } - if (previous.compareTo(current) <= 0) { + if (current.compareTo(previous) <= 0) { throw new IllegalArgumentException("Current version <"+previous+"> must be more recent than previous version <"+current+">."); } //When in development public API is not considered stable @@ -223,7 +223,7 @@ public final class Delta { //Current version must be superior or equals to inferred version final Version inferredVersion = infer(previous); - return inferredVersion.compareTo(current) >= 0; + return current.compareTo(inferredVersion) >= 0; } } diff --git a/api/src/main/java/org/semver/Version.java b/api/src/main/java/org/semver/Version.java index b4c76ee..e6c9abf 100755 --- a/api/src/main/java/org/semver/Version.java +++ b/api/src/main/java/org/semver/Version.java @@ -24,6 +24,7 @@ import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; + import org.apache.commons.lang.StringUtils; /** @@ -159,20 +160,24 @@ public final class Version implements Comparable<Version> { return 0; } - if (other.major > this.major) { - return 1; - } else if (other.major == this.major) { - if (other.minor > this.minor) { - return 1; - } else if (other.minor == this.minor) { - if (other.patch > this.patch) { - return 1; + if (this.major < other.major) { + return -1; + } else if (this.major == other.major) { + if (this.minor < other.minor) { + return -1; + } else if (this.minor == other.minor) { + if (this.patch < other.patch) { + return -1; + } else if (this.special != null && other.special != null) { + return this.special.compareTo(other.special); } else if (other.special != null) { - return other.special.compareTo(this.special); - } + return -1; + } else if (this.special != null) { + return 1; + } // else handled by previous equals check } } - return -1; + return 1; } @Override |