Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,11 @@ public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}

/**
* Sort the exceptions list by licenseExceptionId.
*/
public void sort() {
exceptions.sort((e1, e2) -> e1.getLicenseExceptionId().compareToIgnoreCase(e2.getLicenseExceptionId()));
}

}
11 changes: 11 additions & 0 deletions src/main/java/org/spdx/storage/listedlicense/LicenseJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -557,4 +558,14 @@ public List<PropertyDescriptor> getPropertyValueDescriptors() {
});
return retval;
}

/**
* Sort the crossRef list by order, with URL as a secondary sort key for
* entries with no order set.
*/
public void sortCrossRef() {
crossRef.sort(Comparator
.comparingInt((CrossRefJson c) -> c.order != null ? c.order : Integer.MAX_VALUE)
.thenComparing(c -> c.url != null ? c.url : ""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}

/**
* Sort the licenses list by licenseId.
*/
public void sort() {
licenses.sort((l1, l2) -> l1.getLicenseId().compareToIgnoreCase(l2.getLicenseId()));
}

protected static String toAbsoluteURL(String relURL) {
String retval = relURL.startsWith("./") ? relURL.substring(2) : relURL;
return SpdxConstantsCompatV2.LISTED_LICENSE_URL + retval;
Expand Down
Loading