Skip to content

Commit 36e5ecd

Browse files
authored
Merge pull request #143 from spdx/issue142
Don't store filesAnalyzed if not present
2 parents cd1b91d + 849dea6 commit 36e5ecd

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/main/java/org/spdx/library/model/ModelObject.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ public boolean equivalent(ModelObject compare, boolean ignoreRelatedElements) th
787787
Optional<Object> propertyValueOptional = this.getObjectPropertyValue(propertyName);
788788
if (propertyValueOptional.isPresent()) {
789789
Object propertyValue = propertyValueOptional.get();
790-
if (isEquivalentToNull(propertyValue)) {
790+
if (isEquivalentToNull(propertyValue, propertyName)) {
791791
continue;
792792
}
793793
lastNotEquivalentReason = new NotEquivalentReason(
@@ -805,7 +805,7 @@ public boolean equivalent(ModelObject compare, boolean ignoreRelatedElements) th
805805
continue;
806806
}
807807
Object comparePropertyValue = comparePropertyValueOptional.get();
808-
if (isEquivalentToNull(comparePropertyValue)) {
808+
if (isEquivalentToNull(comparePropertyValue, propertyName)) {
809809
continue;
810810
}
811811
lastNotEquivalentReason = new NotEquivalentReason(
@@ -816,12 +816,16 @@ public boolean equivalent(ModelObject compare, boolean ignoreRelatedElements) th
816816
}
817817

818818
// Some values are treated like null in comparisons - in particular empty model collections and
819-
// "no assertion" values.
820-
private boolean isEquivalentToNull(Object propertyValue) {
819+
// "no assertion" values and a filesAnalyzed filed with a value of true
820+
private boolean isEquivalentToNull(Object propertyValue, String propertyName) {
821821
if (propertyValue instanceof ModelCollection) {
822822
return ((ModelCollection<?>) propertyValue).size() == 0;
823+
} else if (isNoAssertion(propertyValue)) {
824+
return true;
825+
} else if (SpdxConstants.PROP_PACKAGE_FILES_ANALYZED.equals(propertyName)) {
826+
return propertyValue instanceof Boolean && (Boolean)(propertyValue);
823827
} else {
824-
return isNoAssertion(propertyValue);
828+
return false;
825829
}
826830
}
827831

src/main/java/org/spdx/library/model/SpdxPackage.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ public class SpdxPackage extends SpdxItem implements Comparable<SpdxPackage> {
5757
public SpdxPackage() throws InvalidSPDXAnalysisException {
5858
super();
5959
files = new RelatedElementCollection(this, RelationshipType.CONTAINS, SpdxConstants.CLASS_SPDX_FILE);
60-
if (!getBooleanPropertyValue(SpdxConstants.PROP_PACKAGE_FILES_ANALYZED).isPresent()) {
61-
this.setFilesAnalyzed(true); // Set default value
62-
}
6360
}
6461

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

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

9586
protected SpdxPackage(SpdxPackageBuilder spdxPackageBuilder) throws InvalidSPDXAnalysisException {

0 commit comments

Comments
 (0)