Package nl.vpro.util

Class Version<T extends Comparable<T>>

java.lang.Object
nl.vpro.util.Version<T>
All Implemented Interfaces:
Comparable<Version<T>>
Direct Known Subclasses:
IntegerVersion

public class Version<T extends Comparable<T>> extends Object implements Comparable<Version<T>>
A version is basically a string existing of a number of parts.

This base class leaves open how these parts should look like, but we supply an extension where they are integers.

The point is that these things can now be compared in the logical way, such that e.g. 5.12.0 > 5.2.0

Since:
2.2
Author:
Michiel Meeuwissen
  • Field Details

  • Constructor Details

    • Version

      public Version(T... parts)
  • Method Details

    • parseIntegers

      public static @PolyNull IntegerVersion parseIntegers(@PolyNull String string)
      Produces an IntegerVersion, but ignores everything after the first hyphen.

      In that way something like '5.12-SNAPSHOT' will simply be equivalent to '5.12'.

    • parseIntegersOptional

      public static Optional<IntegerVersion> parseIntegersOptional(@Nullable String string)
    • of

      public static IntegerVersion of(int... parts)
    • isAfter

      public boolean isAfter(T... parts)
    • isAfter

      public boolean isAfter(Version<T> other)
    • isNotAfter

      public boolean isNotAfter(T... parts)
    • isNotAfter

      public boolean isNotAfter(Version<T> other)
    • isBefore

      public boolean isBefore(T... parts)
    • isBefore

      public boolean isBefore(Version<T> other)
    • isNotBefore

      public boolean isNotBefore(T... parts)
    • isNotBefore

      public boolean isNotBefore(Version<T> other)
    • compareTo

      public int compareTo(@NonNull Version<T> o)
      Specified by:
      compareTo in interface Comparable<T extends Comparable<T>>
    • 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