You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
This is an internal class. It is not part of the public Jackson API. Jackson is a lib for parsing and generating JSON. It is not a lib for comparing version strings. There are libs that specialise in that sort of thing. Semver4J is one.
Right, maybe Version should not even be Comparable, but the intent definitely is for it to only be used for Jackson components and extension Modules. Latter can be from external developers.
But the main intent is for visibility, and (to a degree) to allow for compatibility comparison wrt version numbers. Classifier String ordering is not really defined, esp. wrt SNAPSHOT vs alpha.
Note on numeric value: I don't think compareTo() is expected to normalized value: they are to be only used for "is it 0, less than 0 or greater than 0" comparison.
With that, I think that:
Is this the intended behavior, or could it be considered a bug? Not a bug
Is the snapshot info string always compared lexicographically? Yes, String qualifier/classifier part is to be sorted lexicographically (without other semantics)
Should users expect comparison results beyond just -1/0/1? Users should not assume only -1/0/1, so yet
Is there any semantic ordering (e.g., "alpha" < "beta" < "rc" < "snapshot"), or is this left entirely to user interpretation? No semantic ordering -- Maven has utility classes for users who'd like to get useful semantic ordering.
Hi,
I came across a case where I was comparing two Version objects like this:
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!
The text was updated successfully, but these errors were encountered: