Class Version

java.lang.Object
com.yubico.yubikit.core.Version
All Implemented Interfaces:
Comparable<Version>

public final class Version extends Object implements Comparable<Version>
A 3-part version number, used by the YubiKey firmware and its various applications.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final byte
     
    final byte
     
    final byte
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Version(byte major, byte minor, byte micro)
    Constructs a new Version object.
    Version(int major, int minor, int micro)
    Constructor using int's for convenience.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
     
    static Version
    fromBytes(byte[] bytes)
    Parses a Version from a byte array by taking the first three bytes.
    byte[]
    Returns the version components as a byte array of size 3.
    int
     
    boolean
    isAtLeast(int major, int minor, int micro)
    Returns whether or not the Version is greater than or equal to a given version.
    boolean
    isLessThan(int major, int minor, int micro)
    Returns whether or not the Version is less than a given version.
    static Version
    parse(String versionString)
    Parses a Version from a String (eg.
     

    Methods inherited from class java.lang.Object

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

    • major

      public final byte major
    • minor

      public final byte minor
    • micro

      public final byte micro
  • Constructor Details

    • Version

      public Version(int major, int minor, int micro)
      Constructor using int's for convenience.

      Each version component will be checked to ensure it falls within an acceptable range.

    • Version

      public Version(byte major, byte minor, byte micro)
      Constructs a new Version object.
  • Method Details

    • getBytes

      public byte[] getBytes()
      Returns the version components as a byte array of size 3.
    • compareTo

      public int compareTo(Version other)
      Specified by:
      compareTo in interface Comparable<Version>
    • isLessThan

      public boolean isLessThan(int major, int minor, int micro)
      Returns whether or not the Version is less than a given version.
    • isAtLeast

      public boolean isAtLeast(int major, int minor, int micro)
      Returns whether or not the Version is greater than or equal to a given version.
    • equals

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

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

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

      public static Version fromBytes(byte[] bytes)
      Parses a Version from a byte array by taking the first three bytes.

      Additional bytes in the array are ignored.

    • parse

      public static Version parse(String versionString)
      Parses a Version from a String (eg. "Firmware version 5.2.1")
      Parameters:
      versionString - string that contains a 3-part version, separated by dots.