Record Class GoVer

java.lang.Object
java.lang.Record
ghidra.app.util.bin.format.golang.GoVer
Record Components:
major - currently just 1
minor - second part of version number, ranges from 0..unknown upper limit
patch - third part of version number, ranges from 0..unknown upper limit per minor version
All Implemented Interfaces:
Comparable<GoVer>

public record GoVer(int major, int minor, int patch) extends Record implements Comparable<GoVer>
Represents a Golang version number (major.minor.patch), with some special sentinel values for wildcarding.
  • Field Details

    • GOLANG_VERSION_PROPERTY_NAME

      public static final String GOLANG_VERSION_PROPERTY_NAME
      See Also:
    • INVALID

      public static final GoVer INVALID
    • ANY

      public static final GoVer ANY
  • Constructor Details

    • GoVer

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

    • parse

      public static GoVer parse(String s)
      Parses a version string ("1.2.0") and returns a GoVer instance, or INVALID if bad data.

      Missing patch numbers will be defaulted to 0.

      Parameters:
      s - string to parse, "1.2.3", or "1.2"
      Returns:
      GoVer instance, or INVALID
    • parseWildcardPatch

      public static GoVer parseWildcardPatch(String s)
      Parses a version string ("1.2.0") and returns a GoVer instance, or INVALID if bad data.

      Missing patch numbers will be replaced with the wildcard value.

      Parameters:
      s - string to parse, "1.2.3", or "1.2"
      Returns:
      GoVer instance, or INVALID
    • fromProgramProperties

      public static GoVer fromProgramProperties(Program program)
      Parses a version string found in a Ghidra program info properties list
      Parameters:
      program - Program
      Returns:
      GoVer instance, or INVALID, never null
    • setProgramPropertiesWithOriginalVersionString

      public static void setProgramPropertiesWithOriginalVersionString(Options props, String s)
      Writes a version string to a Ghidra program info properties list.
      Parameters:
      props - props from a program
      s - version string
    • isInvalid

      public boolean isInvalid()
    • isWildcard

      public boolean isWildcard()
    • getMajor

      public int getMajor()
      Major value
      Returns:
      major
    • getMinor

      public int getMinor()
      Minor value
      Returns:
      minor
    • getPatch

      public int getPatch()
      Patch value
      Returns:
      patch
    • prevPatch

      public GoVer prevPatch()
    • withPatch

      public GoVer withPatch(int newPatchNum)
    • compareTo

      public int compareTo(GoVer o)
      Specified by:
      compareTo in interface Comparable<GoVer>
    • 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. 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