Package aQute.bnd.version.maven
Class ComparableVersion
- java.lang.Object
-
- aQute.bnd.version.maven.ComparableVersion
-
- All Implemented Interfaces:
java.lang.Comparable<ComparableVersion>
public class ComparableVersion extends java.lang.Object implements java.lang.Comparable<ComparableVersion>
Generic implementation of version comparison.
Features:- mixing of '
-' (hyphen) and '.' (dot) separators, - transition between characters and digits also constitutes a separator:
1.0alpha1 => [1, 0, alpha, 1] - unlimited number of version components,
- version components in the text can be digits or strings,
- strings are checked for well-known qualifiers and the qualifier ordering
is used for version ordering. Well-known qualifiers (case insensitive) are:
alphaorabetaorbmilestoneormrcorcrsnapshot(the empty string)orgaorfinalsp
- a hyphen usually precedes a qualifier, and is always less important than something preceded with a dot.
- See Also:
- "Versioning" on Maven Wiki
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classComparableVersion.BigIntegerItemRepresents a numeric item in the version item list.private static classComparableVersion.IntItemRepresents a numeric item in the version item list that can be represented with an int.private static interfaceComparableVersion.Itemprivate static classComparableVersion.ListItemRepresents a version list item.private static classComparableVersion.LongItemRepresents a numeric item in the version item list that can be represented with a long.private static classComparableVersion.StringItemRepresents a string in the version item list, usually a qualifier.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringcanonicalprivate ComparableVersion.ListItemitemsprivate static intMAX_INTITEM_LENGTHprivate static intMAX_LONGITEM_LENGTHprivate java.lang.Stringvalue
-
Constructor Summary
Constructors Constructor Description ComparableVersion(java.lang.String version)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ComparableVersion o)booleanequals(java.lang.Object o)java.lang.StringgetCanonical()inthashCode()private static ComparableVersion.ItemparseItem(boolean isDigit, java.lang.String buf)voidparseVersion(java.lang.String version)private static java.lang.StringstripLeadingZeroes(java.lang.String buf)java.lang.StringtoString()
-
-
-
Field Detail
-
MAX_INTITEM_LENGTH
private static final int MAX_INTITEM_LENGTH
- See Also:
- Constant Field Values
-
MAX_LONGITEM_LENGTH
private static final int MAX_LONGITEM_LENGTH
- See Also:
- Constant Field Values
-
value
private java.lang.String value
-
canonical
private java.lang.String canonical
-
items
private ComparableVersion.ListItem items
-
-
Method Detail
-
parseVersion
public final void parseVersion(java.lang.String version)
-
parseItem
private static ComparableVersion.Item parseItem(boolean isDigit, java.lang.String buf)
-
stripLeadingZeroes
private static java.lang.String stripLeadingZeroes(java.lang.String buf)
-
compareTo
public int compareTo(ComparableVersion o)
- Specified by:
compareToin interfacejava.lang.Comparable<ComparableVersion>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getCanonical
public java.lang.String getCanonical()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-