A package version is a number that identifies the set of components uploaded in a package. The version number has the format majorNumber.minorNumber.patchNumber (for example, 2.1.3). The major and minor numbers increase to a chosen value during every major release. The patchNumber is generated and updated only for a patch release.
The package methods are used by package developers to customize behavior for different package versions. They allow the package developer to continue to support existing behavior in classes and triggers in previous package versions while continuing to evolve the code.
The package methods rely on special objects to allow a class to exhibit different behavior when it references different package versions. These objects can only be used in classes that are in a managed package.
| Name | Arguments | Return Type | Description |
|---|---|---|---|
| isGreaterThan | Package Version Package.Version.major.minor | Boolean | Returns true if the package version is greater than the package version specified in the argument. For example: |
| isGreaterThanOrEqual | Package Version Package.Version.major.minor | Boolean | Returns true if the package version is greater than or equal to the package version specified in the argument. |
| isLessThan | Package Version Package.Version.major.minor | Boolean | Returns true if the package version is less than the package version specified in the argument. |
| isLessThanOrEqual | Package Version Package.Version.major.minor | Boolean | Returns true if the package version is less than or equal to the package version specified in the argument. |
For more information, see Versioning Apex Code Behavior.