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
14 changes: 9 additions & 5 deletions src/main/java/org/spdx/library/model/ModelObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ public boolean equivalent(ModelObject compare, boolean ignoreRelatedElements) th
Optional<Object> propertyValueOptional = this.getObjectPropertyValue(propertyName);
if (propertyValueOptional.isPresent()) {
Object propertyValue = propertyValueOptional.get();
if (isEquivalentToNull(propertyValue)) {
if (isEquivalentToNull(propertyValue, propertyName)) {
continue;
}
lastNotEquivalentReason = new NotEquivalentReason(
Expand All @@ -805,7 +805,7 @@ public boolean equivalent(ModelObject compare, boolean ignoreRelatedElements) th
continue;
}
Object comparePropertyValue = comparePropertyValueOptional.get();
if (isEquivalentToNull(comparePropertyValue)) {
if (isEquivalentToNull(comparePropertyValue, propertyName)) {
continue;
}
lastNotEquivalentReason = new NotEquivalentReason(
Expand All @@ -816,12 +816,16 @@ public boolean equivalent(ModelObject compare, boolean ignoreRelatedElements) th
}

// Some values are treated like null in comparisons - in particular empty model collections and
// "no assertion" values.
private boolean isEquivalentToNull(Object propertyValue) {
// "no assertion" values and a filesAnalyzed filed with a value of true
private boolean isEquivalentToNull(Object propertyValue, String propertyName) {
if (propertyValue instanceof ModelCollection) {
return ((ModelCollection<?>) propertyValue).size() == 0;
} else if (isNoAssertion(propertyValue)) {
return true;
} else if (SpdxConstants.PROP_PACKAGE_FILES_ANALYZED.equals(propertyName)) {
return propertyValue instanceof Boolean && (Boolean)(propertyValue);
} else {
return isNoAssertion(propertyValue);
return false;
}
}

Expand Down
9 changes: 0 additions & 9 deletions src/main/java/org/spdx/library/model/SpdxPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public class SpdxPackage extends SpdxItem implements Comparable<SpdxPackage> {
public SpdxPackage() throws InvalidSPDXAnalysisException {
super();
files = new RelatedElementCollection(this, RelationshipType.CONTAINS, SpdxConstants.CLASS_SPDX_FILE);
if (!getBooleanPropertyValue(SpdxConstants.PROP_PACKAGE_FILES_ANALYZED).isPresent()) {
this.setFilesAnalyzed(true); // Set default value
}
}

/**
Expand All @@ -75,9 +72,6 @@ public SpdxPackage(IModelStore modelStore, String documentUri, String id,
throws InvalidSPDXAnalysisException {
super(modelStore, documentUri, id, copyManager, create);
files = new RelatedElementCollection(this, RelationshipType.CONTAINS, SpdxConstants.CLASS_SPDX_FILE);
if (!getBooleanPropertyValue(SpdxConstants.PROP_PACKAGE_FILES_ANALYZED).isPresent()) {
this.setFilesAnalyzed(true); // Set default value
}
}

/**
Expand All @@ -87,9 +81,6 @@ public SpdxPackage(IModelStore modelStore, String documentUri, String id,
public SpdxPackage(String id) throws InvalidSPDXAnalysisException {
super(id);
files = new RelatedElementCollection(this, RelationshipType.CONTAINS, SpdxConstants.CLASS_SPDX_FILE);
if (!getBooleanPropertyValue(SpdxConstants.PROP_PACKAGE_FILES_ANALYZED).isPresent()) {
this.setFilesAnalyzed(true); // Set default value
}
}

protected SpdxPackage(SpdxPackageBuilder spdxPackageBuilder) throws InvalidSPDXAnalysisException {
Expand Down