Record Class CloudNetVersion

java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.CloudNetVersion
Record Components:
major - the current major version of CloudNet.
minor - the current minor version of CloudNet.
patch - the current patch number of the current CloudNet minor version.
revision - the git revision CloudNet is running on, empty if unknown.
versionType - the current version type of CloudNet (for example snapshot).
versionTitle - the current release title of CloudNet.

public record CloudNetVersion(int major, int minor, int patch, @NonNull String revision, @NonNull String versionType, @NonNull String versionTitle) extends Record
Represents the current version specification which the associated CloudNet component is running on.
Since:
4.0
  • Field Details

    • major

      private final int major
      The field for the major record component.
    • minor

      private final int minor
      The field for the minor record component.
    • patch

      private final int patch
      The field for the patch record component.
    • revision

      @NonNull private final @NonNull String revision
      The field for the revision record component.
    • versionType

      @NonNull private final @NonNull String versionType
      The field for the versionType record component.
    • versionTitle

      @NonNull private final @NonNull String versionTitle
      The field for the versionTitle record component.
    • VERSION_PATTERN

      private static final Pattern VERSION_PATTERN
  • Constructor Details

    • CloudNetVersion

      public CloudNetVersion(int major, int minor, int patch, @NonNull @NonNull String revision, @NonNull @NonNull String versionType, @NonNull @NonNull String versionTitle)
      Creates an instance of a CloudNetVersion record class.
      Parameters:
      major - the value for the major record component
      minor - the value for the minor record component
      patch - the value for the patch record component
      revision - the value for the revision record component
      versionType - the value for the versionType record component
      versionTitle - the value for the versionTitle record component
  • Method Details

    • fromPackage

      @NonNull public static @NonNull CloudNetVersion fromPackage(@NonNull @NonNull Package source)
      Reads and tries to parse the CloudNet version from the information provided by the specified package. This method throws an exception if the given package does not contain valid version information. The version of the package must at least match the semver specification, MAJOR.MINOR.PATCH. If any additional information is supplied this method will try to parse the remaining information from it (revision, version type). The version title is determined by the package implementation title.
      Parameters:
      source - the package to parse the CloudNet version from.
      Returns:
      the parsed CloudNet version instance from the given package.
      Throws:
      NullPointerException - if the given package is null.
      IllegalArgumentException - if the given package doesn't contain parseable data.
    • toString

      @NonNull public @NonNull String toString()
      Converts this version back to a human-readable string. The returned version string always follows the schema:
       CloudNet <VersionTitle> <major>.<minor>.<patch>-<VersionType> [revision]
       
      The revision is only appended if present (not empty).
      Specified by:
      toString in class Record
      Returns:
      the stringified, human-readable representation of this version.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • major

      public int major()
      Returns the value of the major record component.
      Returns:
      the value of the major record component
    • minor

      public int minor()
      Returns the value of the minor record component.
      Returns:
      the value of the minor record component
    • patch

      public int patch()
      Returns the value of the patch record component.
      Returns:
      the value of the patch record component
    • revision

      @NonNull public @NonNull String revision()
      Returns the value of the revision record component.
      Returns:
      the value of the revision record component
    • versionType

      @NonNull public @NonNull String versionType()
      Returns the value of the versionType record component.
      Returns:
      the value of the versionType record component
    • versionTitle

      @NonNull public @NonNull String versionTitle()
      Returns the value of the versionTitle record component.
      Returns:
      the value of the versionTitle record component