raydac / commons-version

Auxiliary framework to parse and check version information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

License Apache 2.0 Maven central Java 8.0+ PayPal donation YooMoney donation

Changes

  • 1.0.1 (SNAPSHOT)

    • updated maven plugin dependencies
    • minimal version of JDK lifted up to 1.8
  • 1.0.0 (31-mar-2016)

    • initial version

What is it?

It is a small auxiliary framework to parse, validate and compare versions defined through string format XXX-NNN.NNN.NN-ZZZZ.

How it works?

It has two main classes

Usage of version

Version parsed=new Version("idea-1.04.0015-alpha");
        Version fullyFromScratch=new Version("idea",new long[]{1,4,15},"alpha");

        Version onlyNumber=new Version(1,4,15);
        Version changed=onlyNumber.changePrefix("idea").changePostfix("alpha").changeNumeric(0,1,2);

Usage of version validator

Validator supports AND (,) and OR (;) logical operators, where AND has higher priority.
Allowed conditions:

  • = equals
  • < less
  • > great
  • >= great or equals
  • <= less or equals
  • if there is no any operator then it will be recognized as =
VersionValidator validator=new VersionValidator(">idea-1.1.0,<idea-3.0.2;1.1.0,3.0.2;!=0.0.1-dev");
        if(validator.isValid(someVersion)){
        System.out.println("Version valid");
}

Also it is possible to implement own expression parser to parse expressions.
NB! Wrong written conditional operator will be recognized as part of the version prefix! Be careful for typo like =>!

About

Auxiliary framework to parse and check version information

License:Apache License 2.0


Languages

Language:Java 100.0%