-
Notifications
You must be signed in to change notification settings - Fork 10
Version checking
The AquariusServerVersion class includes the IsLessThan(AquariusServerVersion other) and Compare(AquariusServerVersion other) predicate methods to quickly compare version numbers correctly to determine if a specific version is older or newer.
If your integration needs to adapt its behaviour based on the server version, this class can sometimes help you work around release-specific quirks.
// Eg. Assume that AQTS 2017.3 introduced a new Foo operation on the Publish API
private static final AquariusServerVersion FooApiExistsVersion
= AquariusServerVersion.Create("17.3");
...
if (client.ServerVersion.IsLessThan(FooApiExistsVersion)) {
// We know we're talking to an older AQTS, which won't have the new API, so don't even try to send the request
return;
}
// The request should be valid, so go ahead and issue it
FooResponse response = new client.Publish.Get(new FooRequest());Version comparison is quite as simple as comparing version strings lexicographically. "3.5" needs to be considered earlier than "17.1.56".
String serverVersion = "3.5";
String myVersion = "17.1.56";
if (serverVersion< myVersion) { // Wrong! String sort-order yields incorrect results
System.out.println("Old server version detected!");
} else {
System.out.println("New server version detected!");
}The above code will do the wrong thing for many types of comparisons.
The AquariusServerVersion.Create(String apiVersion) method takes a dotted-version-string and populates some internal fields to enable efficient comparison:
- Split the string on
'.'boundaries into version components - Parse each component as an integer
- Adjust the first component (the "major" version) to reflect the 20XX.Y.Z naming convention for new AQTS server releases
There is also a toString() method which recomposes the parsed version into string form again.
System.out.println(AquariusServerVersion.Create("17.1.56")"); // Outputs: 2017.1.56All of this logic is verified by the unit test class, so you can have confidence that the IsLessThan() and Compare() predicates behave as expected.
Still have questions? Feel free to raise an issue or contact our Support Team
- SDK design philosophy (on the .NET SDK wiki)
- AQTS client concepts
- AQTS code examples
- Troubleshooting tips