Class Version

  • All Implemented Interfaces:
    Comparable<Version>

    public class Version
    extends Object
    implements Comparable<Version>
    Version identifier for 1C:Enterprise runtime.

    Version consists of three components

    1. Major version. A non-negative integer.
    2. Minor version. A non-negative integer.
    3. Micro version. A non-negative integer.

    Version objects are immutable.

    Restriction:
    This class is not intended to be subclassed by clients.
    • Field Detail

      • V8_3_6

        public static final Version V8_3_6
      • V8_3_7

        public static final Version V8_3_7
      • V8_3_8

        public static final Version V8_3_8
      • V8_3_9

        public static final Version V8_3_9
      • V8_3_10

        public static final Version V8_3_10
      • V8_3_11

        public static final Version V8_3_11
      • V8_3_12

        public static final Version V8_3_12
      • V8_3_13

        public static final Version V8_3_13
      • V8_3_14

        public static final Version V8_3_14
      • V8_3_15

        public static final Version V8_3_15
      • V8_3_16

        public static final Version V8_3_16
      • V8_3_17

        public static final Version V8_3_17
      • V8_3_18

        public static final Version V8_3_18
      • V8_3_19

        public static final Version V8_3_19
      • V8_3_20

        public static final Version V8_3_20
      • LATEST

        public static final Version LATEST
      • EMPTY_VERSION

        public static final Version EMPTY_VERSION
        The empty version "0.0.0".
    • Constructor Detail

      • Version

        public Version​(int major,
                       int minor,
                       int micro)
        Creates a version identifier from the specified numerical components.
        Parameters:
        major - Major component of the version identifier, not negative.
        minor - Minor component of the version identifier, not negative.
        micro - Micro component of the version identifier, not negative.
        Throws:
        IllegalArgumentException - If the numerical components are negative.
      • Version

        public Version​(String version)
        Creates a version identifier from the specified string.

        Version string grammar:

         version ::= major('.'minor('.'micro)?)?
         major ::= digit+
         minor ::= digit+
         micro ::= digit+
         digit ::= [0..9]
         
        Parameters:
        version - String representation of the version identifier. There must be no whitespace in the argument.
        Throws:
        IllegalArgumentException - If version is improperly formatted.
    • Method Detail

      • parseCompatibilityMode

        public static Version parseCompatibilityMode​(CompatibilityMode mode)
        Parse CompatibilityMode to platfrom Version. It will be equals to compatibility mode version.
        Parameters:
        mode - the compatibility mode to parse Version from, cannot be null
        Returns:
        parsed Version, never null
      • parseVersion

        public static Version parseVersion​(String version)
        Parses a version identifier from the specified string.

        See Version(String) for the format of the version string.

        Parameters:
        version - String representation of the version identifier. Leading and trailing whitespace will be ignored.
        Returns:
        A Version object representing the version identifier. If version is null or the empty string then EMPTY_VERSION will be returned.
        Throws:
        IllegalArgumentException - If version is improperly formatted.
      • create

        public static Version create​(String version)
        Parses a version identifier from the specified string.

        Version string grammar:

         version ::= 'major.minor.micro'
         major ::= digit+
         minor ::= digit+
         micro ::= digit+
         digit ::= [0..9]
         

        See Version(String) for the format of the version string.

        Parameters:
        version - String representation of the version identifier. Leading and trailing whitespace will be ignored.
        Returns:
        A Version object representing the version identifier. If version is null or the empty string then null will be returned.
        if version has illegal format null will be returned.
      • isInRange

        public boolean isInRange​(String versionRange)
        Checks if given version is in specified version range and false otherwise.

        Version range string grammar

         range ::= ('['|'(')version(, version)?(']'|')')
         version ::= major('.'minor('.'micro)?)?
         major ::= digit+
         minor ::= digit+
         micro ::= digit+
         digit ::= [0..9]
         

        Example usage:

            Version version = ...
            if (version.isInRange("[8.3.2, 8.3.5)"))
              // do something
         
        Parameters:
        versionRange - the version range (not null).
        Returns:
        true when given version is in specified version range and false otherwise.
        Throws:
        IllegalArgumentException - If versionRange is improperly formatted.
      • isGreaterThan

        public boolean isGreaterThan​(Version that)
        Compares that this Version object is greater than specified Version object
        Parameters:
        that - The Version object to be compared, not null
        Returns:
        true if this version is greater than the specified Version object, false in otherwise
      • isLessThan

        public boolean isLessThan​(Version that)
        Compares that this Version object is less than specified Version object
        Parameters:
        that - The Version object to be compared, not null
        Returns:
        true if this version is less than the specified Version object, false in otherwise
      • getMajor

        public int getMajor()
        Returns the major component of this version identifier.
        Returns:
        The major component.
      • getMinor

        public int getMinor()
        Returns the minor component of this version identifier.
        Returns:
        The minor component.
      • getMicro

        public int getMicro()
        Returns the micro component of this version identifier.
        Returns:
        The micro component.
      • compareTo

        public int compareTo​(Version other)
        Compares this Version object to another Version.

        A version is considered to be less than another version if its major component is less than the other version's major component, or the major components are equal and its minor component is less than the other version's minor component, or the major and minor components are equal and its micro component is less than the other version's micro component.

        A version is considered to be equal to another version if the major, minor and micro components are equal.

        Specified by:
        compareTo in interface Comparable<Version>
        Parameters:
        other - The Version object to be compared, not null
        Returns:
        A negative integer, zero, or a positive integer if this version is less than, equal to, or greater than the specified Version object.
        Throws:
        ClassCastException - If the specified object is not a Version object.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object