Semver.toString() adds additional information to the version string
See original GitHub issuenew Semver("1.0.0", SemverType.NPM).toString()
returns Semver(1.0.0)
.
We are using this in another project to parse two versions and determine whether they are compatible. If they are not we throw an exception with a message that is built this way:
MessageFormat.format("Versions \"{0}\" and \"{1}\" are incompatible", version1, version2);
This results in the following message:
Versions "Semver(1.0.0)" and "Semver(2.0.0)" are incompatible.
while we would like to have this message:
Versions "1.0.0" and "2.0.0" are incompatible.
To achive this we had to modify our code in the following way:
MessageFormat.format("Versions \"{0}\" and \"{1}\" are incompatible", version1.getOriginalValue(), version2.getOriginalValue());
The first approach is cleaner and therefore we would prefer it if toString() did not add “Semver()” to the returned value, if possible.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
I get your problem and I think you’re right. Initially, I wanted a clear distinction between the 3 methods:
(note the spaces)
I guess we could make
toString
return the currentgetValue
. I don’t want to return the original value because I want a “normalized”toString
method.Does that make sense? Would that be ok?
Any update on that? The code change should be trivial…