Class Nice2Version

java.lang.Object
ch.tocco.nice2.toolbox.api.Nice2Version
All Implemented Interfaces:
Comparable<Nice2Version>

public final class Nice2Version extends Object implements Comparable<Nice2Version>

This immutable class represents the nice2 version scheme as described here.

The version consists of four parts, where the last two are optional and default to 0 if not defined explicitely.

Version String:

     major   .   minor   .   fix   .   buildnumber
       2           1          1           32
 

The major part must be greater than 0, all other parts must not be lower than 0. Valid version strings:

     2.1
     2.1.0
     2.1.0.12
 

The major and minor parts are mandatory. The fix and buildnumber part need not be specified and are considered to be 0 then. The build number is a number that is incremented on each subsequent build, no matter if there was a change introduced or not.

  • Field Details

  • Constructor Details

    • Nice2Version

      public Nice2Version(int major, int minor, int fix, int buildnumber)
    • Nice2Version

      public Nice2Version(int major, int minor, int fix)
    • Nice2Version

      public Nice2Version(int major, int minor)
    • Nice2Version

      public Nice2Version(String version)
  • Method Details

    • tryGetVersion

      public static Optional<Nice2Version> tryGetVersion(String version)
    • findVersion

      public static Optional<Nice2Version> findVersion(String str)
      Attemps to find a substring that matches the version pattern and returns it parsed to a version object.
    • getCurrent

      public static Optional<Nice2Version> getCurrent()
      Gets the current nice2 version. At first, the system property nice2.version is examined.
    • getCurrentRevision

      public static Optional<String> getCurrentRevision()
    • getMajor

      public int getMajor()
    • getMinor

      public int getMinor()
    • getFix

      public int getFix()
    • getBuildnumber

      public int getBuildnumber()
    • asCompleteString

      public String asCompleteString()
    • asShortString

      public String asShortString()
    • withBuildNumber

      public Nice2Version withBuildNumber(int buildnumber)
    • withBuildNumberAdded

      public Nice2Version withBuildNumberAdded(int arg)
    • withFix

      public Nice2Version withFix(int fix)
    • withFixAdded

      public Nice2Version withFixAdded(int arg)
    • withMinor

      public Nice2Version withMinor(int minor)
    • withMinorAdded

      public Nice2Version withMinorAdded(int arg)
    • withMajor

      public Nice2Version withMajor(int major)
    • withMajorAdded

      public Nice2Version withMajorAdded(int arg)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Nice2Version o)
      Specified by:
      compareTo in interface Comparable<Nice2Version>