Class Version

  • All Implemented Interfaces:
    java.lang.Comparable<Version>

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

      Fields 
      Modifier and Type Field Description
      byte major  
      byte micro  
      byte minor  
    • 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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Version other)  
      boolean equals​(java.lang.Object o)  
      static Version fromBytes​(byte[] bytes)
      Parses a Version from a byte array by taking the first three bytes.
      byte[] getBytes()
      Returns the version components as a byte array of size 3.
      int hashCode()  
      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​(java.lang.String versionString)
      Parses a Version from a String (eg.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • major

        public final byte major
      • minor

        public final byte minor
      • micro

        public final byte micro
    • Constructor Detail

      • 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 Detail

      • 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 java.lang.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​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.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​(java.lang.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.