Version
Date: 2016-02-08

org.apache.avalon.framework

## Class Version

- java.lang.Object
- - org.apache.avalon.framework.Version

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable

      public final class Version
      extends java.lang.Object
      implements java.lang.Comparable, java.io.Serializable

  This class is used to hold version information pertaining to a Component or interface.

  The version number of a `Component` is made up of three dot-separated fields:

  "major.minor.micro"

  The major, minor and micro fields are integer numbers represented in decimal notation and have the following meaning:

  - major - When the major version changes (in ex. from "1.5.12" to "2.0.0"), then backward compatibility with previous releases is not granted.

  - minor - When the minor version changes (in ex. from "1.5.12" to "1.6.0"), then backward compatibility with previous releases is granted, but something changed in the implementation of the Component. (ie it methods could have been added)

  - micro - When the micro version changes (in ex. from "1.5.12" to "1.5.13"), then the the changes are small forward compatible bug fixes or documentation modifications etc.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Version(int major, int minor, int micro)` Create a new instance of a `Version` object with the specified version numbers.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(java.lang.Object o)` Compare two versions together according to the `Comparable` interface.
    `boolean` | `complies(Version other)` Check this `Version` against another for compliancy (compatibility).
    `boolean` | `equals(java.lang.Object other)` Indicates whether some other object is "equal to" this `Version`.
    `boolean` | `equals(Version other)` Check this `Version` against another for equality.
    `int` | `getMajor()` Retrieve major component of version.
    `int` | `getMicro()` Retrieve micro component of version.
    `int` | `getMinor()` Retrieve minor component of version.
    `static Version` | `getVersion(java.lang.String version)` Parse a version out of a string.
    `int` | `hashCode()` Add a hashing function to ensure the Version object is treated as expected in hashmaps and sets.
    `java.lang.String` | `toString()` Overload toString to report version correctly.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Version

          public Version(int major,
                 int minor,
                 int micro)

      Create a new instance of a `Version` object with the specified version numbers.
      Parameters:
        `major` - This `Version` major number.
        `minor` - This `Version` minor number.
        `micro` - This `Version` micro number.

  - ### Method Detail

    - #### getVersion

          public static Version getVersion(java.lang.String version)
                                    throws java.lang.NumberFormatException,
                                           java.lang.IllegalArgumentException

      Parse a version out of a string. The version string format is .. where both minor and micro are optional.
      Parameters:
        `version` - The input version string
      Returns:
        the new Version object
      Throws:
        `java.lang.NumberFormatException` - if an error occurs
        `java.lang.IllegalArgumentException` - if an error occurs
        `java.lang.NullPointerException` - if the provided string is `null`
      Since:
        4.1

    - #### getMajor

          public int getMajor()

      Retrieve major component of version.
      Returns:
        the major component of version
      Since:
        4.1

    - #### getMinor

          public int getMinor()

      Retrieve minor component of version.
      Returns:
        the minor component of version
      Since:
        4.1

    - #### getMicro

          public int getMicro()

      Retrieve micro component of version.
      Returns:
        the micro component of version.
      Since:
        4.1

    - #### equals

          public boolean equals(Version other)

      Check this `Version` against another for equality.

      If this `Version` is compatible with the specified one, then true is returned, otherwise false.
      Parameters:
        `other` - The other `Version` object to be compared with this for equality.
      Returns:
        true if this `Version` is compatible with the specified one
      Since:
        4.1

    - #### equals

          public boolean equals(java.lang.Object other)

      Indicates whether some other object is "equal to" this `Version`. Returns true if the other object is an instance of `Version` and has the same major, minor, and micro components.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `other` - an `Object` value
      Returns:
        true if the other object is equal to this `Version`

    - #### hashCode

          public int hashCode()

      Add a hashing function to ensure the Version object is treated as expected in hashmaps and sets. NOTE: any time the equals() is overridden, hashCode() should also be overridden.
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        the hashCode

    - #### complies

          public boolean complies(Version other)

      Check this `Version` against another for compliancy (compatibility).

      If this `Version` is compatible with the specified one, then true is returned, otherwise false. Be careful when using this method since, in example, version 1.3.7 is compliant to version 1.3.6, while the opposite is not.

      The following example displays the expected behaviour and results of version.

           final Version v1 = new Version( 1, 3 , 6 );
           final Version v2 = new Version( 1, 3 , 7 );
           final Version v3 = new Version( 1, 4 , 0 );
           final Version v4 = new Version( 2, 0 , 1 );

           assert(   v1.complies( v1 ) );
           assert( ! v1.complies( v2 ) );
           assert(   v2.complies( v1 ) );
           assert( ! v1.complies( v3 ) );
           assert(   v3.complies( v1 ) );
           assert( ! v1.complies( v4 ) );
           assert( ! v4.complies( v1 ) );

      Parameters:
        `other` - The other `Version` object to be compared with this for compliancy (compatibility).
      Returns:
        true if this `Version` is compatible with the specified one

    - #### toString

          public java.lang.String toString()

      Overload toString to report version correctly.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        the dot seperated version string

    - #### compareTo

          public int compareTo(java.lang.Object o)

      Compare two versions together according to the `Comparable` interface.
      Specified by:
        `compareTo` in interface `java.lang.Comparable`
      Returns:
        number indicating relative value (-1, 0, 1)