Class Version

java.lang.Object
org.springframework.data.util.Version
All Implemented Interfaces:
Comparable<Version>

public class Version extends Object implements Comparable<Version>
Value object to represent a Version consisting of major, minor and bugfix part.
Author:
Oliver Gierke
  • Constructor Details

    • Version

      public Version(int... parts)
      Creates a new Version from the given integer values. At least one value has to be given but a maximum of 4.
      Parameters:
      parts - must not be null or empty.
  • Method Details

    • parse

      public static Version parse(String version)
      Parses the given string representation of a version into a Version object.
      Parameters:
      version - must not be null or empty.
      Returns:
    • javaVersion

      public static Version javaVersion()
      Returns the Java version of the running JVM.
      Returns:
      will never be null.
    • isGreaterThan

      public boolean isGreaterThan(Version version)
      Returns whether the current Version is greater (newer) than the given one.
      Parameters:
      version -
      Returns:
    • isGreaterThanOrEqualTo

      public boolean isGreaterThanOrEqualTo(Version version)
      Returns whether the current Version is greater (newer) or the same as the given one.
      Parameters:
      version -
      Returns:
    • is

      public boolean is(Version version)
      Returns whether the current Version is the same as the given one.
      Parameters:
      version -
      Returns:
    • isLessThan

      public boolean isLessThan(Version version)
      Returns whether the current Version is less (older) than the given one.
      Parameters:
      version -
      Returns:
    • isLessThanOrEqualTo

      public boolean isLessThanOrEqualTo(Version version)
      Returns whether the current Version is less (older) or equal to the current one.
      Parameters:
      version -
      Returns:
    • compareTo

      public int compareTo(Version that)
      Specified by:
      compareTo in interface Comparable<Version>
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object