Class VersionNumber

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<VersionNumber>

    @AlfrescoPublicApi
    public final class VersionNumber
    extends java.lang.Object
    implements java.lang.Comparable<VersionNumber>, java.io.Serializable
    Immutable class to encapsulate a version number string. A valid version number string can be made up of any number of numberical parts all delimited by '.'.
    Author:
    Roy Wetherall
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      VersionNumber​(java.lang.String version)
      Constructror, expects a valid version string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(VersionNumber obj)
      Compares the passed version to this.
      boolean equals​(java.lang.Object obj)
      Equals implementation
      int getPart​(int index)
      Helper method to the the part based on the index, if an invalid index is supplied 0 is returned.
      int[] getParts()
      Get the various parts of the version
      int hashCode()
      Hash code implementation
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • VERSION_ZERO

        public static final VersionNumber VERSION_ZERO
        A convenient '0' version
      • VERSION_BIG

        public static final VersionNumber VERSION_BIG
        A convenient '999' version
    • Constructor Detail

      • VersionNumber

        public VersionNumber​(java.lang.String version)
        Constructror, expects a valid version string. A AlfrescoRuntimeException will be throw if an invalid version is encountered.
        Parameters:
        version - the version string
    • Method Detail

      • getParts

        public int[] getParts()
        Get the various parts of the version
        Returns:
        array containing the parts of the version
      • compareTo

        public int compareTo​(VersionNumber obj)
        Compares the passed version to this. Determines whether they are equal, greater or less than this version.
        Specified by:
        compareTo in interface java.lang.Comparable<VersionNumber>
        Parameters:
        obj - the other version number
        Returns:
        -1 if the passed version is less that this, 0 if they are equal, 1 if the passed version is greater
      • getPart

        public int getPart​(int index)
        Helper method to the the part based on the index, if an invalid index is supplied 0 is returned.
        Parameters:
        index - the index
        Returns:
        the part value, 0 if the index is invalid
      • hashCode

        public int hashCode()
        Hash code implementation
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Equals implementation
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object