Class TorVersion

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

    public class TorVersion
    extends java.lang.Object
    implements java.lang.Comparable<TorVersion>
    Helper class to compare Tor versions.

    Based on "How Tor Version Numbers Work", available at https://gitweb.torproject.org/torspec.git/tree/version-spec.txt

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(TorVersion other)  
      TorVersionStatus determineVersionStatus​(java.util.SortedSet<TorVersion> recommendedVersions)
      Determine the version status of this tor version in the context of the given recommended tor versions.
      boolean equals​(java.lang.Object other)  
      int hashCode()  
      boolean matchingPrefix​(TorVersion other)
      Return whether prefixes of this version and another version match.
      static TorVersion of​(java.lang.String versionString)
      Return a TorVersion instance from the given tor version string that can be compared to other tor version strings, or null if the given string is not a valid tor version.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • of

        public static TorVersion of​(java.lang.String versionString)
        Return a TorVersion instance from the given tor version string that can be compared to other tor version strings, or null if the given string is not a valid tor version.
      • compareTo

        public int compareTo​(TorVersion other)
        Specified by:
        compareTo in interface java.lang.Comparable<TorVersion>
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • matchingPrefix

        public boolean matchingPrefix​(TorVersion other)
        Return whether prefixes of this version and another version match.

        Two versions A and B have the same prefix if A starts with B, B starts with A, or A and B are the same.

      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • determineVersionStatus

        public TorVersionStatus determineVersionStatus​(java.util.SortedSet<TorVersion> recommendedVersions)
        Determine the version status of this tor version in the context of the given recommended tor versions.