Skip to content

Commit

Permalink
Make licenseInfoInFile optional in SdpxFileBuilder
Browse files Browse the repository at this point in the history
Fixes #130

Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
  • Loading branch information
goneall committed Oct 13, 2022
1 parent 4d82aa5 commit 2a641d6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/org/spdx/library/model/SpdxFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ protected SpdxFile(SpdxFileBuilder spdxFileBuilder) throws InvalidSPDXAnalysisEx
setName(spdxFileBuilder.name);
setLicenseConcluded(spdxFileBuilder.concludedLicense);
addChecksum(spdxFileBuilder.sha1);
getLicenseInfoFromFiles().addAll(spdxFileBuilder.licenseInfosFromFile);

// optional parameters - SpdxElement
getAnnotations().addAll(spdxFileBuilder.annotations);
Expand All @@ -99,7 +98,9 @@ protected SpdxFile(SpdxFileBuilder spdxFileBuilder) throws InvalidSPDXAnalysisEx
// optional parameters - SpdxItem
setLicenseComments(spdxFileBuilder.licenseComments);
getAttributionText().addAll(spdxFileBuilder.attributionText);

if (Objects.nonNull(spdxFileBuilder.licenseInfosFromFile)) {
getLicenseInfoFromFiles().addAll(spdxFileBuilder.licenseInfosFromFile);
}
// optional parameters - SpdxFile
Iterator<Checksum> iter = spdxFileBuilder.checksums.iterator();
while (iter.hasNext()) {
Expand Down Expand Up @@ -328,7 +329,6 @@ public static class SpdxFileBuilder {

// required fields - SpdxItem
AnyLicenseInfo concludedLicense;
Collection<AnyLicenseInfo> licenseInfosFromFile;
String copyrightText;

// required fields - SpdxFile
Expand All @@ -342,6 +342,7 @@ public static class SpdxFileBuilder {
// optional fields - SpdxItem
String licenseComments = null;
Collection<String> attributionText = new ArrayList<String>();
Collection<AnyLicenseInfo> licenseInfosFromFile;

// optional fields - SpdxFile
Collection<Checksum> checksums = new ArrayList<Checksum>();
Expand All @@ -363,13 +364,13 @@ public static class SpdxFileBuilder {
*/
public SpdxFileBuilder(IModelStore modelStore, String documentUri, String id,
@Nullable ModelCopyManager copyManager, String name,
AnyLicenseInfo concludedLicense, Collection<AnyLicenseInfo> licenseInfosFromFile,
AnyLicenseInfo concludedLicense,
@Nullable Collection<AnyLicenseInfo> licenseInfosFromFile,
String copyrightText, Checksum sha1) {
Objects.requireNonNull(modelStore, "Model store can not be null");
Objects.requireNonNull(documentUri, "Document URI can not be null");
Objects.requireNonNull(id, "ID can not be null");
Objects.requireNonNull(name, "Name can not be null");
Objects.requireNonNull(licenseInfosFromFile, "License info from files can not be null");
Objects.requireNonNull(sha1, "SHA1 can not be null");
this.modelStore = modelStore;
this.documentUri = documentUri;
Expand Down

0 comments on commit 2a641d6

Please sign in to comment.