Class NuixVersion

  • All Implemented Interfaces:
    java.lang.Comparable<NuixVersion>

    public class NuixVersion
    extends java.lang.Object
    implements java.lang.Comparable<NuixVersion>
    Assists in representing a Nuix version in object form to assist with comparing two versions. This allows for things such as only executing chunks of code if the version meets a requirement.
    Ruby example:
     
     current_version = NuixVersion.new(NUIX_VERSION)
     if current_version.isLessThan("7.8.0.10")
         puts "Sorry your version of Nuix is below the minimum required version of 7.8.0.10"
         exit 1
     end
     
     
    • Constructor Summary

      Constructors 
      Constructor Description
      NuixVersion()
      Creates a new instance defaulting to version 0.0.0
      NuixVersion​(int majorVersion)
      Creates a new instance using the provided major version: major.0.0.0
      NuixVersion​(int majorVersion, int minorVersion)
      Creates a new instance using the provided major and minor versions: major.minor.0.0
      NuixVersion​(int majorVersion, int minorVersion, int bugfixVersion)
      Creates a new instance using the provided major, minor and bugfix versions: major.minor.bugfix.0
      NuixVersion​(int majorVersion, int minorVersion, int bugfixVersion, int buildVersion)
      Creates a new instance using the provided major, minor, bugfix and build versions: major.minor.bugfix.build
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(NuixVersion other)
      Provides comparison logic when comparing two instances.
      int getBugfix()
      Gets the determined bugfix portion of this version instance (0.0.x.0)
      int getBuild()
      Gets the determined build portion of this version instance (0.0.0.x)
      static NuixVersion getCurrent()
      Attempts to determine current Nuix version by inspecting Nuix packages.
      int getMajor()
      Gets the determined major portion of this version instance (X.0.0.0)
      int getMinor()
      Gets the determined minor portion of this version instance (0.X.0.0)
      boolean isAtLeast​(NuixVersion other)
      Determines whether another instance's version is greater than or equal to this instance
      boolean isAtLeast​(java.lang.String other)
      Determines whether another instance's version is greater than or equal to this instance
      boolean isEqualTo​(NuixVersion other)
      Determines whether another instance's version is equal to this instance
      boolean isEqualTo​(java.lang.String other)
      Determines whether another instance's version is equal to this instance
      boolean isGreaterThan​(NuixVersion other)
      Determines whether another instance's version is greater than this instance
      boolean isGreaterThan​(java.lang.String other)
      Determines whether another instance's version is greater than this instance
      boolean isLessThan​(NuixVersion other)
      Determines whether another instance's version is less than this instance
      boolean isLessThan​(java.lang.String other)
      Determines whether another instance's version is less than this instance
      static NuixVersion parse​(java.lang.String versionString)
      Parses a version string into a NuixVersion instance.
      void setBugfix​(int bugfix)
      Sets the determined bugfix portion of this version instance (0.0.x.0)
      void setBuild​(int build)
      Sets the build portion of this version instance (0.0.0.x)
      void setMajor​(int major)
      Sets the major portion of this version instance (X.0.0.0)
      void setMinor​(int minor)
      Sets the minor portion of this version instance (0.X.0.0)
      java.lang.String toString()
      Converts this instance back to a version string from its components, such as: "7.8.0.10"
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NuixVersion

        public NuixVersion()
        Creates a new instance defaulting to version 0.0.0
      • NuixVersion

        public NuixVersion​(int majorVersion)
        Creates a new instance using the provided major version: major.0.0.0
        Parameters:
        majorVersion - The major version number
      • NuixVersion

        public NuixVersion​(int majorVersion,
                           int minorVersion)
        Creates a new instance using the provided major and minor versions: major.minor.0.0
        Parameters:
        majorVersion - The major version number
        minorVersion - The minor version number
      • NuixVersion

        public NuixVersion​(int majorVersion,
                           int minorVersion,
                           int bugfixVersion)
        Creates a new instance using the provided major, minor and bugfix versions: major.minor.bugfix.0
        Parameters:
        majorVersion - The major version number
        minorVersion - The minor version number
        bugfixVersion - The bugfix version number
      • NuixVersion

        public NuixVersion​(int majorVersion,
                           int minorVersion,
                           int bugfixVersion,
                           int buildVersion)
        Creates a new instance using the provided major, minor, bugfix and build versions: major.minor.bugfix.build
        Parameters:
        majorVersion - The major version number
        minorVersion - The minor version number
        bugfixVersion - The bugfix version number
        buildVersion - The build version number
    • Method Detail

      • parse

        public static NuixVersion parse​(java.lang.String versionString)
        Parses a version string into a NuixVersion instance. Supports values such as: 6, 6.2, 6.2.0, 6.2.1-preview6, 7.8.0.10
        When providing a version string such as "6.2.1-preview6", "-preview6" will be trimmed off before parsing.
        Parameters:
        versionString - The version string to parse.
        Returns:
        A NuixVersion instance representing the supplied version string, if there is an error parsing the provided value will return an instance representing 900.0.0.0
      • getMajor

        public int getMajor()
        Gets the determined major portion of this version instance (X.0.0.0)
        Returns:
        The determined major portion of version
      • setMajor

        public void setMajor​(int major)
        Sets the major portion of this version instance (X.0.0.0)
        Parameters:
        major - The major version value
      • getMinor

        public int getMinor()
        Gets the determined minor portion of this version instance (0.X.0.0)
        Returns:
        The determined minor portion of version
      • setMinor

        public void setMinor​(int minor)
        Sets the minor portion of this version instance (0.X.0.0)
        Parameters:
        minor - The minor version value
      • getBugfix

        public int getBugfix()
        Gets the determined bugfix portion of this version instance (0.0.x.0)
        Returns:
        The determined bugfix portion of version
      • setBugfix

        public void setBugfix​(int bugfix)
        Sets the determined bugfix portion of this version instance (0.0.x.0)
        Parameters:
        bugfix - The determined bugfix portion of version
      • getBuild

        public int getBuild()
        Gets the determined build portion of this version instance (0.0.0.x)
        Returns:
        The determined build portion of version
      • setBuild

        public void setBuild​(int build)
        Sets the build portion of this version instance (0.0.0.x)
        Parameters:
        build - The build version value
      • getCurrent

        public static NuixVersion getCurrent()
        Attempts to determine current Nuix version by inspecting Nuix packages. It is preffered to instead use parse(String) when version string is available, such as in Ruby using constant NUIX_VERSION.
        Returns:
        Best guess at current Nuix version based on package inspection.
      • isLessThan

        public boolean isLessThan​(NuixVersion other)
        Determines whether another instance's version is less than this instance
        Parameters:
        other - The other instance to compare against
        Returns:
        True if the other instance is a lower version, false otherwise
      • isAtLeast

        public boolean isAtLeast​(NuixVersion other)
        Determines whether another instance's version is greater than or equal to this instance
        Parameters:
        other - The other instance to compare against
        Returns:
        True if the other instance is greater than or equal to this instance, false otherwise
      • isGreaterThan

        public boolean isGreaterThan​(NuixVersion other)
        Determines whether another instance's version is greater than this instance
        Parameters:
        other - The other instance to compare against
        Returns:
        True if the other instance is greater than this instance, false otherwise
      • isGreaterThan

        public boolean isGreaterThan​(java.lang.String other)
        Determines whether another instance's version is greater than this instance
        Parameters:
        other - The other instance to compare against
        Returns:
        True if the other instance is greater than this instance, false otherwise
      • isEqualTo

        public boolean isEqualTo​(NuixVersion other)
        Determines whether another instance's version is equal to this instance
        Parameters:
        other - The other instance to compare against
        Returns:
        True if the other instance is greater than this instance, false otherwise
      • isEqualTo

        public boolean isEqualTo​(java.lang.String other)
        Determines whether another instance's version is equal to this instance
        Parameters:
        other - The other instance to compare against
        Returns:
        True if the other instance is equal to this instance (major, minor and release are the same), false otherwise
      • isLessThan

        public boolean isLessThan​(java.lang.String other)
        Determines whether another instance's version is less than this instance
        Parameters:
        other - A version string to compare against
        Returns:
        True if the other instance is a lower version, false otherwise
      • isAtLeast

        public boolean isAtLeast​(java.lang.String other)
        Determines whether another instance's version is greater than or equal to this instance
        Parameters:
        other - A version string to compare against
        Returns:
        True if the other instance is greater than or equal to this instance, false otherwise
      • compareTo

        public int compareTo​(NuixVersion other)
        Provides comparison logic when comparing two instances.
        Specified by:
        compareTo in interface java.lang.Comparable<NuixVersion>
      • toString

        public java.lang.String toString()
        Converts this instance back to a version string from its components, such as: "7.8.0.10"
        Overrides:
        toString in class java.lang.Object