java.lang.Object
org.torproject.metrics.descriptorparser.utils.TorVersion
All Implemented Interfaces:
Comparable<TorVersion>

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

Based on "How Tor Version Numbers Work", available at https://gitlab.torproject.org/tpo/core/torspec/-/blob/main/version-spec.txt

  • Method Details

    • of

      public static TorVersion of(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 Comparable<TorVersion>
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class 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 Object
    • toString

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

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