|
11 | 11 | import org.cyclonedx.Version; |
12 | 12 | import org.cyclonedx.model.Metadata; |
13 | 13 | import org.cyclonedx.model.Property; |
14 | | -import org.cyclonedx.model.component.evidence.Occurrence; |
15 | 14 | import org.cyclonedx.model.metadata.ToolInformation; |
16 | 15 |
|
17 | 16 | import static org.cyclonedx.util.serializer.SerializerUtils.shouldSerializeField; |
@@ -67,7 +66,7 @@ private void createMetadataInfo( |
67 | 66 | //Tools |
68 | 67 | parseTools(metadata, jsonGenerator); |
69 | 68 |
|
70 | | - if (metadata.getAuthors() != null && shouldSerializeField(metadata, version, "author")) { |
| 69 | + if (CollectionUtils.isNotEmpty(metadata.getAuthors()) && shouldSerializeField(metadata, version, "author")) { |
71 | 70 | if (isXml) { |
72 | 71 | ToXmlGenerator xmlGenerator = (ToXmlGenerator) jsonGenerator; |
73 | 72 | writeArrayFieldXML(metadata.getAuthors(), xmlGenerator, "author"); |
@@ -132,18 +131,18 @@ else if (version.getVersion() >= Version.VERSION_15.getVersion()) { |
132 | 131 | jsonGenerator.writeFieldName("tools"); |
133 | 132 | jsonGenerator.writeStartObject(); |
134 | 133 | if (isXml && jsonGenerator instanceof ToXmlGenerator) { |
135 | | - if (choice.getComponents() != null) { |
| 134 | + if (CollectionUtils.isNotEmpty(choice.getComponents())) { |
136 | 135 | writeArrayFieldXML(choice.getComponents(), (ToXmlGenerator) jsonGenerator, "component"); |
137 | 136 | } |
138 | | - if (choice.getServices() != null) { |
| 137 | + if (CollectionUtils.isNotEmpty(choice.getServices())) { |
139 | 138 | writeArrayFieldXML(choice.getServices(), (ToXmlGenerator) jsonGenerator, "service"); |
140 | 139 | } |
141 | 140 | } |
142 | 141 | else { |
143 | | - if (choice.getComponents() != null) { |
| 142 | + if (CollectionUtils.isNotEmpty(choice.getComponents())) { |
144 | 143 | writeArrayFieldJSON(jsonGenerator, "components", choice.getComponents()); |
145 | 144 | } |
146 | | - if (choice.getServices() != null) { |
| 145 | + if (CollectionUtils.isNotEmpty(choice.getServices())) { |
147 | 146 | writeArrayFieldJSON(jsonGenerator, "services", choice.getServices()); |
148 | 147 | } |
149 | 148 | } |
|
0 commit comments