Class Version

  • All Implemented Interfaces:
    java.lang.Comparable

    public class Version
    extends java.lang.Object
    implements java.lang.Comparable
    Version.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NOT_AVAILABLE
      The Constant NOT_AVAILABLE.
    • Constructor Summary

      Constructors 
      Constructor Description
      Version()
      Constructor.
      Version​(int nMajor, int nMinor, int nPatch, java.lang.String strQualifier)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.lang.Object object)
      Compare to.
      int getMajor()
      Gets the major.
      int getMinor()
      Gets the minor.
      static java.util.List<java.lang.String> getNextReleaseVersions​(java.lang.String strPreviousReleaseVersion)
      Get a list of next versions for a given version.
      static java.util.List<java.lang.String> getNextReleaseVersions​(java.lang.String strPreviousSnapshotVersion, java.lang.String strPreviousReleaseVersion)
      Get a list of next versions for a given version.
      static java.lang.String getNextSnapshotVersion​(java.lang.String strVersion)
      Get the next snapshot version for a given version.
      int getPatch()
      Gets the patch.
      java.lang.String getQualifier()
      Gets the qualifier.
      static java.lang.String getReleaseVersion​(java.lang.String strVersion)
      Get the next release version for a given version.
      java.lang.String getVersion()
      Gets the version.
      boolean isBeta()
      Returns true if the version is qualified as Beta.
      static boolean isBeta​(java.lang.String strVersion)
      Check if a given version is a RELEASE BETA.
      boolean isCandidate()
      Returns true if the version is qualified as Candidate.
      static boolean isCandidate​(java.lang.String strVersion)
      Check if a given version is a RELEASE CANDIDATE.
      boolean isSnapshot()
      Returns true if the version is qualified as Snapshot.
      static boolean isSnapshot​(java.lang.String strVersion)
      Check if a given version is a SNAPSHOT.
      Version nextMajor​(boolean bSnapshot)
      Build a new version object with major digit incremented.
      Version nextMinor​(boolean bSnapshot)
      Build a new version object with minor digit incremented.
      Version nextPatch​(boolean bSnapshot)
      Build a new version object with patch digit incremented.
      Version nextRelease()
      Build a new version object with no qualifier.
      static Version parse​(java.lang.String strSource)
      Parse a string to extract version.
      void setMajor​(int nMajor)
      Sets the major.
      void setMinor​(int nMinor)
      Sets the minor.
      void setPatch​(int nPatch)
      Sets the patch.
      void setQualifier​(java.lang.String strQualifier)
      Sets the qualifier.
      Version snapshot()
      returns the snapshot version.
      java.lang.String toString()
      .
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NOT_AVAILABLE

        public static final java.lang.String NOT_AVAILABLE
        The Constant NOT_AVAILABLE.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Version

        public Version()
        Constructor.
      • Version

        public Version​(int nMajor,
                       int nMinor,
                       int nPatch,
                       java.lang.String strQualifier)
        Constructor.
        Parameters:
        nMajor - major digit
        nMinor - minor digit
        nPatch - patch digit
        strQualifier - qualifier
    • Method Detail

      • getMajor

        public int getMajor()
        Gets the major.
        Returns:
        the nMajor
      • setMajor

        public void setMajor​(int nMajor)
        Sets the major.
        Parameters:
        nMajor - the nMajor to set
      • getMinor

        public int getMinor()
        Gets the minor.
        Returns:
        the nMinor
      • setMinor

        public void setMinor​(int nMinor)
        Sets the minor.
        Parameters:
        nMinor - the nMinor to set
      • getPatch

        public int getPatch()
        Gets the patch.
        Returns:
        the nPatch
      • setPatch

        public void setPatch​(int nPatch)
        Sets the patch.
        Parameters:
        nPatch - the nPatch to set
      • getQualifier

        public java.lang.String getQualifier()
        Gets the qualifier.
        Returns:
        the Qualifier
      • setQualifier

        public void setQualifier​(java.lang.String strQualifier)
        Sets the qualifier.
        Parameters:
        strQualifier - the Qualifier to set
      • compareTo

        public int compareTo​(java.lang.Object object)
        Compare to.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        object - the object
        Returns:
        the int
      • getVersion

        public java.lang.String getVersion()
        Gets the version.
        Returns:
        the version
      • toString

        public java.lang.String toString()
        .
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string
      • snapshot

        public Version snapshot()
        returns the snapshot version.
        Returns:
        the snapshot version
      • nextMajor

        public Version nextMajor​(boolean bSnapshot)
        Build a new version object with major digit incremented.
        Parameters:
        bSnapshot - if snapshot qualifier needed
        Returns:
        The next version object
      • nextMinor

        public Version nextMinor​(boolean bSnapshot)
        Build a new version object with minor digit incremented.
        Parameters:
        bSnapshot - if snapshot qualifier needed
        Returns:
        The next version object
      • nextPatch

        public Version nextPatch​(boolean bSnapshot)
        Build a new version object with patch digit incremented.
        Parameters:
        bSnapshot - if snapshot qualifier needed
        Returns:
        The next version object
      • nextRelease

        public Version nextRelease()
        Build a new version object with no qualifier.
        Returns:
        The next version object
      • isSnapshot

        public boolean isSnapshot()
        Returns true if the version is qualified as Snapshot.
        Returns:
        true if the version is qualified as Snapshot
      • isCandidate

        public boolean isCandidate()
        Returns true if the version is qualified as Candidate.
        Returns:
        true if the version is qualified as Candidate
      • isBeta

        public boolean isBeta()
        Returns true if the version is qualified as Beta.
        Returns:
        true if the version is qualified as Beta
      • isSnapshot

        public static boolean isSnapshot​(java.lang.String strVersion)
        Check if a given version is a SNAPSHOT.
        Parameters:
        strVersion - The version to check
        Returns:
        True if snapshot otherwise false
      • isCandidate

        public static boolean isCandidate​(java.lang.String strVersion)
        Check if a given version is a RELEASE CANDIDATE.
        Parameters:
        strVersion - The version to check
        Returns:
        True if candidate otherwise false
      • isBeta

        public static boolean isBeta​(java.lang.String strVersion)
        Check if a given version is a RELEASE BETA.
        Parameters:
        strVersion - The version to check
        Returns:
        True if beta otherwise false
      • getNextReleaseVersions

        public static java.util.List<java.lang.String> getNextReleaseVersions​(java.lang.String strPreviousSnapshotVersion,
                                                                              java.lang.String strPreviousReleaseVersion)
        Get a list of next versions for a given version.
        Parameters:
        strPreviousReleaseVersion - The current version*
        strPreviousSnapshotVersion - The current Snapshot version
        Returns:
        The list
      • getNextReleaseVersions

        public static java.util.List<java.lang.String> getNextReleaseVersions​(java.lang.String strPreviousReleaseVersion)
        Get a list of next versions for a given version.
        Parameters:
        strPreviousReleaseVersion - The current version
        Returns:
        The list
      • getNextSnapshotVersion

        public static java.lang.String getNextSnapshotVersion​(java.lang.String strVersion)
        Get the next snapshot version for a given version.
        Parameters:
        strVersion - The current version
        Returns:
        The version
      • getReleaseVersion

        public static java.lang.String getReleaseVersion​(java.lang.String strVersion)
        Get the next release version for a given version.
        Parameters:
        strVersion - The current version
        Returns:
        The version