class ArtifactAndLicenseComparator implements Comparator<ArtifactAndLicense>, Serializable {

   @Override
   public int compare(ArtifactAndLicense o1, ArtifactAndLicense o2) {
      boolean b1 = o1.getPurl().isPresent();
      boolean b2 = o2.getPurl().isPresent();

      int compared = 0;
      if (b1 && b2) {
         compared = String.CASE_INSENSITIVE_ORDER.compare(o1.getPurl().get(), o2.getPurl().get());
      }
      if (compared == 0) {
         compared = String.CASE_INSENSITIVE_ORDER.compare(o1.getFilename(), o2.getFilename());
      }
      return compared;
   }

}