-
Notifications
You must be signed in to change notification settings - Fork 1
Utils Version Parser
SimplixCore offers a class called Version
for comparing version strings. This is mainly used by the builtin automatic update checker.
SimplixCore is able to parse standard sequence version strings like "v#.#.#" or "#.#.#" with a maximum of three number levels (major, minor and patch values).
Version version = Version.parse("1.2.3");
If you are using a different versioning scheme, you can provide your own regular expression for parsing your version strings.
Version version = Version.parse("^(\\d+\\.)?(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$", "1.2.3.4");
The Version
class is implementing Comparable<Version>
so it can be used in many ways for comparing versions. This class is also providing simple newerThen
and olderThen
methods to directly compare two versions.
Version v1 = Version.parse("1.2.3");
Version v2 = Version.parse("1.4");
if (v1.olderThen(v2)) {
// Expected since 1.2.3 is older then 1.4
}
if (v2.newerThen(v1)) {
// Expected since 1.4 is newer then 1.2.3
}
You can only compare versions against each other that are using the same versioning scheme. Otherwise an IllegalArgumentException
will occur.
2020 - SimplixSoftworks
- Introduction
- Getting started
- Maven Dependencies
- How to use the Dependency-Injection
- Localization
- Listener API
- SQL
- Libraries
- Utilities
- Contribute