Maybe it's better to use some library for this comparison? Maybe maven provides such functionality? Or [java-semver](https://github.com/zafarkhaja/java-semver)?