package org.sonar.plugins.stash;

import java.text.MessageFormat;
import java.util.Comparator;
import java.util.List;
import org.sonar.api.rule.Severity;

public class SeverityComparator implements Comparator<String> {
    private List<String> severities = Severity.ALL;

    @Override
    public int compare(String o1, String o2) {
      int io1 = indexOf(o1);
      int io2 = indexOf(o2);

      if (io1 == io2) {
        return 0;
      }
      if (io1 > io2) {
        return 1;
      }
      return -1;
    }

    private int indexOf(String o) {
      int r = severities.indexOf(o);
      if (r == -1) {
        throw new IllegalArgumentException(
            MessageFormat.format("Invalid Severity \"{0}\", expecting one of {1}", o, severities)
        );
      }
      return r;
    }
}

@@ -336,175 +336,69 @@
     
-int io1 = indexOf(o1);%0A      int io2 = indexOf(o2);%0A%0A      if (io1 == io2) %7B%0A        return 0;%0A      %7D%0A      if (io1 %3E io2) %7B%0A        return 1;%0A      %7D%0A      return -1
+return Comparator.comparingInt(this::indexOf).compare(o1, o2)
 ;%0A  

simplify SeverityComparator