Class Version

  • All Implemented Interfaces:
    Serializable, Comparable<Version>

    public final class Version
    extends Object
    implements Comparable<Version>, Serializable
    A version for a module. Versions are series of letters and digits, optionally divided by separator characters, which include ., -, +, and _. The transition between letter and digit (or vice-versa) is also considered to be an invisible separator.

    Versions may be compared, sorted, used as hash keys, and iterated.

    Author:
    David M. Lloyd
    See Also:
    Serialized Form
    • Method Detail

      • parse

        public static Version parse​(String v)
        Parses the given string as a version string.
        Parameters:
        v - The string to parse
        Returns:
        The resulting Version
        Throws:
        IllegalArgumentException - If v is null, an empty string, or cannot be parsed as a version string
      • iterator

        public Version.Iterator iterator()
        Construct a new iterator over the parts of this version string.
        Returns:
        the iterator
      • compareTo

        public int compareTo​(Version that)
        Compares this module version to another module version. Module versions are compared as described in the class description.
        Specified by:
        compareTo in interface Comparable<Version>
        Parameters:
        that - The module version to compare
        Returns:
        A negative integer, zero, or a positive integer as this module version is less than, equal to, or greater than the given module version
      • equals

        public boolean equals​(Object ob)
        Tests this module version for equality with the given object.

        If the given object is not a Version then this method returns false. Two module version are equal if their corresponding components are equal.

        This method satisfies the general contract of the Object.equals method.

        Overrides:
        equals in class Object
        Parameters:
        ob - the object to which this object is to be compared
        Returns:
        true if, and only if, the given object is a module reference that is equal to this module reference
      • hashCode

        public int hashCode()
        Computes a hash code for this module version.

        The hash code is based upon the components of the version and satisfies the general contract of the Object.hashCode method.

        Overrides:
        hashCode in class Object
        Returns:
        The hash-code value for this module version
      • toString

        public String toString()
        Returns the normalized string representation of this version.
        Overrides:
        toString in class Object
        Returns:
        The normalized string.