Record Class Version

java.lang.Object
java.lang.Record
fr.skytasul.reflection.Version
All Implemented Interfaces:
Comparable<Version>

public record Version(int major, int minor, int patch) extends Record implements Comparable<Version>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Version
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Version(int major, int minor, int patch)
    Creates an instance of a Version record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    is(int major, int minor, int patch)
    Checks if this version is the same as the version passed as parameters.
    boolean
    is(@NotNull Version version)
    Checks if this version is the same as the version passed as parameters.
    boolean
    isAfter(int major, int minor, int patch)
    Checks if this version is after or equal to the version passed as parameters.
    boolean
    isAfter(@NotNull Version version)
    Checks if this version is after or equal to the version passed as parameters.
    boolean
    isBefore(int major, int minor, int patch)
    Checks if this version is strictly before the version passed as parameters.
    boolean
    isBefore(@NotNull Version version)
    Checks if this version is strictly before the version passed as parameters.
    int
    Returns the value of the major record component.
    int
    Returns the value of the minor record component.
    static @NotNull Version
    parse(@NotNull String string)
     
    static @NotNull Version @NotNull []
    parseArray(String... versions)
     
    int
    Returns the value of the patch record component.
    final @NotNull String
    Returns a string representation of this record class.
    final @NotNull String
    toString(boolean omitPatch)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ZERO

      public static final Version ZERO
  • Constructor Details

    • Version

      public Version(int major, int minor, int patch)
      Creates an instance of a Version 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
  • Method Details

    • is

      public boolean is(int major, int minor, int patch)
      Checks if this version is the same as the version passed as parameters.
      Parameters:
      major -
      minor -
      patch -
      Returns:
      true if the current version is exactly the same as the passed version
    • is

      public boolean is(@NotNull @NotNull Version version)
      Checks if this version is the same as the version passed as parameters.
      Parameters:
      version -
      Returns:
      true if the current version is exactly the same as the passed version
      See Also:
    • isAfter

      public boolean isAfter(int major, int minor, int patch)
      Checks if this version is after or equal to the version passed as parameters.
      Parameters:
      major -
      minor -
      patch -
      Returns:
      true if the current version is after (inclusive) the passed version
    • isAfter

      public boolean isAfter(@NotNull @NotNull Version version)
      Checks if this version is after or equal to the version passed as parameters.
      Parameters:
      version -
      Returns:
      true if the current version is after (inclusive) the passed version
    • isBefore

      public boolean isBefore(int major, int minor, int patch)
      Checks if this version is strictly before the version passed as parameters.
      Parameters:
      major -
      minor -
      patch -
      Returns:
      true if the current version is before (exclusive) the passed version
    • isBefore

      public boolean isBefore(@NotNull @NotNull Version version)
      Checks if this version is strictly before the version passed as parameters.
      Parameters:
      version -
      Returns:
      true if the current version is before (exclusive) the passed version
    • compareTo

      public int compareTo(Version o)
      Specified by:
      compareTo in interface Comparable<Version>
    • toString

      @NotNull public final @NotNull String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • toString

      @NotNull public final @NotNull String toString(boolean omitPatch)
    • parse

      @NotNull public static @NotNull Version parse(@NotNull @NotNull String string) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • parseArray

      @NotNull public static @NotNull Version @NotNull [] parseArray(String... versions)
    • 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. All components in this record class are compared with '=='.
      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