@groovy.transform.CompileStatic class VersionComparator extends java.lang.Object implements java.util.Comparator<java.lang.String>
A comparator that orders versions from oldest to newest, following the standard java.util.Comparator contract (a negative result means the first version is older).
Versions are compared by their numeric components first (major, minor, patch, ...),
padding the shorter side with zeros so that 7.0 and 7.0.0 are equal.
When the numeric components are equal the version qualifier is used as a tie-breaker
following the same ordering as org.grails.datastore.mapping.core.grailsversion.GrailsVersion:
7.0.0-M1 < 7.0.0-M2 < 7.0.0-RC1 < 7.0.0-RC2 < 7.0.0-SNAPSHOT < 7.0.0
In other words a milestone is older than a release candidate, a release candidate is
older than a snapshot, and any qualified (pre-release) version is older than the final
release of the same number. Both the dotted (7.0.0.M1) and hyphenated
(7.0.0-M1) qualifier forms are treated as equivalent. Unrecognised qualifiers are
treated as a final release to preserve backwards compatible behaviour.
| Constructor and description |
|---|
VersionComparator() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
int |
compare(java.lang.String o1, java.lang.String o2) |
|
protected java.lang.String |
deSnapshot(java.lang.String version)Removes any suffixes that indicate that the version is a kind of snapshot |
|
boolean |
equals(java.lang.Object obj) |
|
protected boolean |
isSnapshot(java.lang.String version) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Removes any suffixes that indicate that the version is a kind of snapshot