Class VersionNumber

java.lang.Object
com.seeq.utilities.VersionNumber
All Implemented Interfaces:
Comparable<VersionNumber>

public class VersionNumber extends Object implements Comparable<VersionNumber>
A utility class that understands semantic versioning for comparisons. While this is based on a SemanticVersion class that came from cassandra 2.0, an external library could be used if needed. Feel free to add other methods to expose the actual major.minor.patch if you need them.
  • Constructor Details

    • VersionNumber

      public VersionNumber(String version)
  • Method Details

    • removeMarketingPrefix

      public static String removeMarketingPrefix(String versionString)
      Strip the RXX. prefix. So for a version like R19.0.36.03, pull out "R19." and leave just 0.36.03. For a version like R50.0.1, pull out "R" and leave just 50.0.1.
      Parameters:
      versionString - The version string to strip the prefix from.
      Returns:
      The version string with the prefix removed, if necessary.
    • shouldUpgrade

      public static boolean shouldUpgrade(VersionNumber upgradeAtVersion, VersionNumber fromVersion, VersionNumber toVersion)
      Default method to test whether an upgrade should apply. The function returns true if 'upgradeAtVersion' is greater than 'fromVersion' and less than or equal to 'toVersion'.
      Parameters:
      upgradeAtVersion - the first version of Seeq where the upgrade should apply
      fromVersion - the previously-installed version of Seeq
      toVersion - the current version of Seeq
      Returns:
      true if the upgrade should be applied
    • compareTo

      public int compareTo(VersionNumber other)
      Specified by:
      compareTo in interface Comparable<VersionNumber>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • readVersionNumberFromFile

      public static Optional<VersionNumber> readVersionNumberFromFile(Path path) throws IOException
      Throws:
      IOException
    • assertUpgradeAllowed

      public static void assertUpgradeAllowed(RuntimeVersion buildVersion, Path versionPath) throws IOException
      Asserts that upgrades from the current version (as determined by the version.txt file at versionPath) are supported.
      Parameters:
      buildVersion - - The current build version
      versionPath - - The path to version.txt
      Throws:
      IOException - - If the version.txt can't be read
    • assertUpgradeAllowed

      public static void assertUpgradeAllowed(Optional<VersionNumber> maybeFrom, VersionNumber to)
      Asserts that upgrades from the specified 'from' version to the specified 'to' version are supported. The logic here must be kept in sync with the logic in _check_upgrade_compatibility from common/migrations/_impl.py.
      Parameters:
      maybeFrom - The 'from' version. If empty, this signifies that the current version is unknown (i.e., there is no version.txt file) and calculates an upgrade path starting at 0.37.XX.
      to - The 'to' version.