Class StaticVersionComparator

java.lang.Object
org.openrewrite.nodejs.internal.StaticVersionComparator
All Implemented Interfaces:
Comparator<Version>

public class StaticVersionComparator extends Object implements Comparator<Version>
Allows for comparison of Version instances. Note that this comparator only considers the 'parts' of a version, and does not consider the part 'separators'. This means that it considers `1.1.1 == 1-1-1 == 1.1-1`, and should not be used in cases where this is important. One example where this comparator is inappropriate is if versions should be retained in a TreeMap/TreeSet.
Copied from org.openrewrite.java.dependencies.internal.StaticVersionComparator.
  • Constructor Details

    • StaticVersionComparator

      public StaticVersionComparator()
  • Method Details

    • compare

      public int compare(Version version1, Version version2)
      Compares 2 versions. Algorithm is inspired by PHP version_compare one.
      Specified by:
      compare in interface Comparator<Version>