Class Version

java.lang.Object
org.graylog2.plugin.Version
All Implemented Interfaces:
Comparable<Version>

public class Version extends Object implements Comparable<Version>
  • Field Details

  • Constructor Details

  • Method Details

    • from

      public static Version from(int major, int minor, int patch)
      Build valid Version from major, minor, and patch version ("X.Y.Z").
      Parameters:
      major - The major version component.
      minor - The minor version component.
      patch - The patch version component.
      Returns:
      The Version instance built from the given parameters.
    • from

      public static Version from(int major, int minor, int patch, String preRelease)
      Build valid Version from major, minor, and patch version ("X.Y.Z").
      Parameters:
      major - The major version component.
      minor - The minor version component.
      patch - The patch version component.
      preRelease - The pre-release version component.
      Returns:
      The Version instance built from the given parameters.
    • from

      public static Version from(int major, int minor, int patch, String preRelease, String buildMetadata)
      Build valid Version from major, minor, and patch version ("X.Y.Z").
      Parameters:
      major - The major version component.
      minor - The minor version component.
      patch - The patch version component.
      preRelease - The pre-release version component.
      buildMetadata - Additional build metadata (e. g. the Git commit SHA).
      Returns:
      The Version instance built from the given parameters.
    • fromPluginProperties

      public static Version fromPluginProperties(Class<?> pluginClass, String path, String propertyName, Version defaultVersion)
      Try to read the version from the graylog-plugin.properties file included in a plugin.
      Parameters:
      pluginClass - Class where the class loader should be obtained from.
      path - Path of the properties file on the classpath which contains the version information.
      propertyName - The name of the property to read as project version ("major.minor.patch-preReleaseVersion").
      defaultVersion - The Version to return if reading the information from the properties files failed.
    • fromPluginProperties

      public static Version fromPluginProperties(Class<?> pluginClass, String path, String propertyName, String gitPath, String gitPropertyName, Version defaultVersion)
      Try to read the version from the graylog-plugin.properties file included in a plugin and git.properties (git.commit.id property) from the classpath..
      Parameters:
      pluginClass - Class where the class loader should be obtained from.
      path - Path of the properties file on the classpath which contains the version information.
      propertyName - The name of the property to read as project version ("major.minor.patch-preReleaseVersion").
      gitPath - Path of the properties file on the classpath which contains the SCM information.
      gitPropertyName - The name of the property to read as git commit SHA.
      defaultVersion - The Version to return if reading the information from the properties files failed.
    • fromClasspathProperties

      public static Version fromClasspathProperties(Version defaultVersion)
      Try to read the version from version.properties (project.version property) and git.properties (git.commit.id property) from the classpath.
      Parameters:
      defaultVersion - The Version to return if reading the information from the properties files failed.
    • fromClasspathProperties

      public static Version fromClasspathProperties(String path, String gitPath, Version defaultVersion)
      Try to read the version from path (project.version property) and gitPath (git.commit.id property) from the classpath.
      Parameters:
      path - Path of the properties file on the classpath which contains the version information.
      gitPath - Path of the properties file on the classpath which contains the SCM information.
      defaultVersion - The Version to return if reading the information from the properties files failed.
    • fromClasspathProperties

      public static Version fromClasspathProperties(String path, String propertyName, String gitPath, String gitPropertyName, Version defaultVersion)
      Try to read the version from path (propertyName property) and gitPath (gitPropertyName property) from the classpath.
      Parameters:
      path - Path of the properties file on the classpath which contains the version information.
      propertyName - The name of the property to read as project version ("major.minor.patch-preReleaseVersion").
      gitPath - Path of the properties file on the classpath which contains the SCM information.
      gitPropertyName - The name of the property to read as git commit SHA.
      defaultVersion - The Version to return if reading the information from the properties files failed.
    • fromClasspathProperties

      public static Version fromClasspathProperties(@Nonnull Class<?> clazz, String path, String propertyName, String gitPath, String gitPropertyName, Version defaultVersion)
      Try to read the version from path (propertyName property) and gitPath (gitPropertyName property) from the classpath.
      Parameters:
      clazz - Class where the class loader should be obtained from.
      path - Path of the properties file on the classpath which contains the version information.
      propertyName - The name of the property to read as project version ("major.minor.patch-preReleaseVersion").
      gitPath - Path of the properties file on the classpath which contains the SCM information.
      gitPropertyName - The name of the property to read as git commit SHA.
      defaultVersion - The Version to return if reading the information from the properties files failed.
    • getVersion

      public com.github.zafarkhaja.semver.Version getVersion()
      Returns:
      the underlying Version instance.
    • toString

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

      @Deprecated public boolean greaterMinor(Version other)
      Deprecated.
      Check if this version is higher than the passed other version. Only taking major and minor version number in account.
      Parameters:
      other - Version to compare
    • sameOrHigher

      public boolean sameOrHigher(Version other)
      See Also:
      • Version.greaterThanOrEqualTo(com.github.zafarkhaja.semver.Version)
    • equals

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

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

      public int compareTo(@Nonnull Version that)
      Specified by:
      compareTo in interface Comparable<Version>