Record Class SoftwareVersion

java.lang.Object
java.lang.Record
is.galia.util.SoftwareVersion
Record Components:
major - Major version.
minor - Minor version.
patch - Patch version.
qualifier - String following the version, such as rc1, -SNAPSHOT, etc.
All Implemented Interfaces:
Comparable<SoftwareVersion>

public record SoftwareVersion(int major, int minor, int patch, String qualifier) extends Record implements Comparable<SoftwareVersion>
Software version supporting n.n.n-qualifier syntax.
  • Constructor Details

    • SoftwareVersion

      public SoftwareVersion(int major)
      Creates an n.0 instance.
      Parameters:
      major - Major version.
    • SoftwareVersion

      public SoftwareVersion(int major, int minor)
      Creates an n.n instance.
      Parameters:
      major - Major version.
      minor - Minor version.
    • SoftwareVersion

      public SoftwareVersion(int major, int minor, int patch)
      Creates an n.n.n instance.
      Parameters:
      major - Major version.
      minor - Minor version.
      patch - Patch version.
    • SoftwareVersion

      public SoftwareVersion(int major, int minor, int patch, String qualifier)
      Creates an instance of a SoftwareVersion 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
      qualifier - the value for the qualifier record component
  • Method Details

    • parse

      public static SoftwareVersion parse(String version)
      Parameters:
      version - Version string.
      Throws:
      IllegalArgumentException - if the string cannot be parsed.
    • compareTo

      public int compareTo(SoftwareVersion other)
      Behaves similarly to isGreaterThan(SoftwareVersion) except returns 0 for equal instances.
      Specified by:
      compareTo in interface Comparable<SoftwareVersion>
      Parameters:
      other - The object to be compared.
      Returns:
      Whether the instance is greater than, equal to, or less than the given instance.
    • isGreaterThan

      public boolean isGreaterThan(SoftwareVersion other)
      Parameters:
      other - Instance to compare against.
      Returns:
      Whether the instance is greater than the given version.
    • toString

      public 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
    • 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
    • qualifier

      public String qualifier()
      Returns the value of the qualifier record component.
      Returns:
      the value of the qualifier record component