Package org.wildfly.plugin.tools
Class VersionComparator
java.lang.Object
org.wildfly.plugin.tools.VersionComparator
- All Implemented Interfaces:
Comparator<String>
Compares two versions. The comparison is case-insensitive.
Some qualifiers map to other qualifiers. Below is a table of those mappings.
| Qualifier | Mapping |
|---|---|
| GA | Final |
| a | Alpha |
| b | Beta |
| m | Milestone |
| cr | rc |
- Author:
- James R. Perkins
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintstatic intcompareVersion(boolean ignoreSnapshots, String v1, String v2) Compares the first version against the second version optionally ignoring if either version has a SNAPSHOT release extension.static intcompareVersion(String v1, String v2) Compares the first version against the second version.static VersionComparatorReturns an instance of a version comparator.static VersionComparatorgetInstance(boolean ignoreSnapshots) Returns an instance of a version comparator which optionally ignore the SNAPSHOT release extension.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
VersionComparator
public VersionComparator()Creates a new version comparator.
-
-
Method Details
-
getInstance
Returns an instance of a version comparator.- Returns:
- a version comparator instance
-
getInstance
Returns an instance of a version comparator which optionally ignore the SNAPSHOT release extension. This can be useful for cases where you want to compare a version is at least a base version, not caring if it's a SNAPSHOT.- Parameters:
ignoreSnapshots-trueto ignore the SNAPSHOT release extension, otherwisefalsewhich values a SNAPSHOT dependency less than a non-SNAPSHOT of the same version- Returns:
- a version comparator instance
-
compareVersion
Compares the first version against the second version.- Parameters:
v1- first versionv2- second version- Returns:
0if the versions are equal,-1if version first version is less than the second version or1if the first version is greater than the second version- See Also:
-
compareVersion
Compares the first version against the second version optionally ignoring if either version has a SNAPSHOT release extension. This can be useful for cases where you want to compare a version is at least a base version, not caring if it's a SNAPSHOT.If
ignoreSnapshotsistrue, the version1.0.0.Finaland1.0.0.Final-SNAPSHOTare said to be equal. If set tofalse,1.0.0.Finalis greater than1.0.0.Final-SNAPSHOT.- Parameters:
ignoreSnapshots-trueto ignore the SNAPSHOT release extension, otherwisefalsewhich values a SNAPSHOT dependency less than a non-SNAPSHOT of the same versionv1- the first versionv2- the second version- Returns:
0if the versions are equal,-1if version first version is less than the second version or1if the first version is greater than the second version
-
compare
- Specified by:
comparein interfaceComparator<String>
-