package org.joda.modulenames;

import java.util.List;

/** Raw data item. */
class Item {

  final String line;

  final String mavenGroupId;
  final String mavenArtifactId;
  final String mavenVersion;
  final String mavenGroupColonArtifact;

  final String moduleName;
  final String moduleVersion;
  final String moduleMode;
  final List<String> moduleDependencies;

  final String jdepsToolError;
  final List<String> jdepsViolations;

  // https://github.com/sandermak/modulescanner/blob/master/src/main/java/org/adoptopenjdk/modulescanner/SeparatedValuesPrinter.java
  Item(String line) {
    this.line = line;
    var values = line.split(",");
    if (values.length < 9) {
      throw new IllegalArgumentException(
          "Expected at least 9 values, only got " + values.length + " in: " + line);
    }
    //
    this.mavenGroupId = blankIfDash(values[0]);
    this.mavenArtifactId = blankIfDash(values[1]);
    this.mavenVersion = blankIfDash(values[2]);
    this.mavenGroupColonArtifact = mavenGroupId + ':' + mavenArtifactId;
    //
    this.moduleName = blankIfDash(values[3]);
    this.moduleVersion = blankIfDash(values[4]);
    this.moduleMode = blankIfDash(values[5]);
    this.moduleDependencies = List.of(values[6].split(" \\+ "));
    //
    this.jdepsToolError = blankIfDash(values[7]);
    this.jdepsViolations = List.of(values[8].split(" \\+ "));
  }

  @Override
  public String toString() {
    return line;
  }

  private static String blankIfDash(String value) {
    return "-".equals(value) ? "" : value;
  }
}

@@ -46,16 +46,42 @@
 il.List;
+%0Aimport java.util.Objects;
 %0A%0A/** Ra
@@ -96,16 +96,22 @@
 tem. */%0A
+final 
 class It
@@ -112,16 +112,44 @@
 ass Item
+ implements Comparable%3CItem%3E
  %7B%0A%0A  fi
@@ -1430,16 +1430,429 @@
 );%0A  %7D%0A%0A
+  @Override%0A  public int compareTo(Item other) %7B%0A    return line.compareTo(other.line);%0A  %7D%0A%0A  @Override%0A  public boolean equals(Object obj) %7B%0A    if (obj == null) %7B%0A      return false;%0A    %7D%0A    if (!(obj instanceof Item)) %7B%0A      return false;%0A    %7D%0A    var other = (Item) obj;%0A    return Objects.equals(this.line, other.line);%0A  %7D%0A%0A  @Override%0A  public int hashCode() %7B%0A    return Objects.hashCode(line);%0A  %7D%0A%0A
   @Overr

Make Item comparable using its line for comparison