public class ComparableVersion extends Object implements Comparable<ComparableVersion>
Generic implementation of version comparison.
Features:-
' (hyphen) and '.
' (dot) separators,1.0alpha1 => [1, 0, alpha, 1]
alpha
or a
beta
or b
milestone
or m
rc
or cr
snapshot
(the empty string)
or ga
or final
sp
Constructor and Description |
---|
ComparableVersion(String version) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ComparableVersion o) |
boolean |
equals(Object o) |
String |
getCanonical() |
int |
hashCode() |
static void |
main(String... args)
Main to test version parsing and comparison.
|
void |
parseVersion(String version) |
String |
toString() |
public ComparableVersion(String version)
public final void parseVersion(String version)
public int compareTo(ComparableVersion o)
compareTo
in interface Comparable<ComparableVersion>
public String getCanonical()
public static void main(String... args)
To check how "1.2.7" compares to "1.2-SNAPSHOT", for example, you can issue
java -jar ${maven.repo.local}/org/apache/maven/maven-artifact/${maven.version}/maven-artifact-${maven.version}.jar "1.2.7" "1.2-SNAPSHOT"command to command line. Result of given command will be something like this:
Display parameters as parsed by Maven (in canonical form) and comparison result: 1. 1.2.7 == 1.2.7 1.2.7 > 1.2-SNAPSHOT 2. 1.2-SNAPSHOT == 1.2-snapshot
args
- the version strings to parse and compare. You can pass arbitrary number of version strings and always
two adjacent will be comparedCopyright © 2001–2018 The Apache Software Foundation. All rights reserved.