kherge / java.semver Goto Github PK
View Code? Open in Web Editor NEWA library to parse, compare, and constrain semantic version numbers.
A library to parse, compare, and constrain semantic version numbers.
The getBuild()
and getPreRelease()
methods will return empty arrays if metadata is not present. While not terrible, checks can lead to the following type of code:
String[] metadata = version.getPreRelease();
if (metadata.length > 0) {
// ...
}
It would be a minor convenience if an Optional
was returned.
version.getPreRelease().ifPresent(doSomething);
While VersionException
may be applicable to other library classes in the future, the InvalidVersionException
is a tad bit misleading and is strictly used by the parser inside of the Version
class. To clear things up, InvalidVersionException
should be made an inner class to Version
and renamed to InvalidStringException
.
Since the version number is a value object, it does not make much sense to use a list of strings over an immutable array of strings.
The regular expression was found in issue #232 on the semver repository.
Give credit to @DavidFichtmueller.
Templates need to be added for opening issues and creating pull requests.
When parsing the numbers (i.e. major, minor, patch), the NumberFormatException
should be caught and used as a cause for a new InvalidVersionException
.
When creating a new instance, the constructor should not permit numbers (i.e. major, minor, patch) less than 0
(zero).
The source code has not been checked for conformance to the Google Java style guide.
Modify build.gradle
to check for style conformance.
This semver class from another library has the right idea on how to handle comparing integer vs integer and alpha vs alpha metadata. This should replace the way it is handled in my implementation.
A isPreRelease()
method should be added to check if a version number is a pre-release version number.
return (major == 0) || !preRelease.isEmpty();
Tag a 1.0.0
release and publish to Maven Central.
When the pre
and stable
constraints were added, the documentation for version constraints was not updated to include their use.
Add new and
constraints to the example using pre
and stable
.
The Version
class should define a constant, SPEC
that is an instance of Version
that matches the version of the specification the Version
class supports.
public static final SPEC = new Version(2, 0, 0);
The metadata values must be validated to ensure that the conform to spec.
0
(zero).0
(zero).There is no bundled constraints for enforcing stability.
Create two new constraints.
PreRelease
- Requires that a version be a pre-release version.Stable
- Requires that the version be a stable version.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.