Class ComparableVersion

  • All Implemented Interfaces:
    Comparable<ComparableVersion>

    public class ComparableVersion
    extends Object
    implements Comparable<ComparableVersion>
    Generic implementation of version comparison.

    Features:

    • mixing of '-' (dash) 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:
      • alpha or a
      • beta or b
      • milestone or m
      • rc or cr
      • snapshot
      • (the empty string) or ga or final
      • sp
      Unknown qualifiers are considered after known qualifiers, with lexical order (always case insensitive),
    • a dash usually precedes a qualifier, and is always less important than something preceded with a dot.

    Author:
    Kenney Westerhof, Hervé Boutemy
    See Also:
    "Versioning" on Maven Wiki
    • Constructor Detail

      • ComparableVersion

        public ComparableVersion​(String version)
        Instantiates a new comparable version.
        Parameters:
        version - the version
    • Method Detail

      • parseVersion

        public final void parseVersion​(String version)
        Parses the version.
        Parameters:
        version - the version
      • getCanonical

        public String getCanonical()
        Gets the canonical.
        Returns:
        the canonical
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • main

        public static void main​(String... args)
        Main to test version parsing and comparison.
        Parameters:
        args - the version strings to parse and compare