-
-
Notifications
You must be signed in to change notification settings - Fork 816
Description
Hi,
I came across a case where I was comparing two Version objects like this:
Version version1 = new Version(1, 0, 0, "alpha");
Version version2 = new Version(1, 0, 0, "snapshot");
int result = version1.compareTo(version2);
System.out.println(result); // returns -18
I was a bit confused by the result -18, which comes from a lexicographical comparison of the snapshot info strings. I had initially expected "alpha" to be considered newer than "snapshot", or for the comparison to return a normalized result like -1, 0, or 1.
I’d like to ask:
-
Is this the intended behavior, or could it be considered a bug?
-
Is the snapshot info string always compared lexicographically?
-
Should users expect comparison results beyond just -1/0/1?
-
Is there any semantic ordering (e.g., "alpha" < "beta" < "rc" < "snapshot"), or is this left entirely to user interpretation?
Clarifying this in the Javadoc or documentation would help prevent confusion for users relying on version comparison behavior.
Thanks!