Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make licenseInfoInFile optional in SdpxFileBuilder #133

Merged
merged 1 commit into from
Oct 14, 2022
Merged
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
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