3131import com .fasterxml .jackson .databind .JsonSerializer ;
3232import com .fasterxml .jackson .databind .SerializerProvider ;
3333import com .fasterxml .jackson .databind .annotation .JsonSerialize ;
34+ import com .fasterxml .jackson .dataformat .xml .annotation .JacksonXmlProperty ;
35+ import com .fasterxml .jackson .dataformat .xml .annotation .JacksonXmlRootElement ;
3436import org .svip .compare .conflicts .Conflict ;
3537import org .svip .compare .conflicts .ConflictFactory ;
3638import org .svip .sbom .model .interfaces .generics .Component ;
6163 */
6264// todo - release notes
6365@ JsonPropertyOrder ({"type" , "mime-type" , "bom-ref" , "supplier" , "author" , "publisher" , "group" , "name" , "version" , "description" , "scope" , "hashes" , "licenses" , "copyright" , "cpe" , "purl" , "externalReferences" , "properties" })
66+ @ JacksonXmlRootElement (localName = "component" )
6467public class CDX14ComponentObject implements CDX14Package {
6568
6669 /**
6770 * Component's type
6871 */
72+ @ JsonProperty ("type" )
73+ @ JacksonXmlProperty (localName = "type" , isAttribute = true )
6974 private final String type ;
7075
7176 /**
7277 * Component's uid
7378 */
79+ @ JsonProperty ("bom-ref" )
80+ @ JacksonXmlProperty (localName = "bom-ref" , isAttribute = true )
7481 private final String uid ;
7582
7683 /**
7784 * Component's author
7885 */
86+ @ JsonProperty ("author" )
7987 private final String author ;
8088
8189 /**
8290 * Component's name
8391 */
92+ @ JsonProperty ("name" )
8493 private final String name ;
8594
8695 /**
8796 * Component's licenses
8897 */
98+ @ JsonProperty ("licenses" )
99+ @ JsonSerialize (using = CDX14LicenseCollectionSerializer .class )
89100 private final LicenseCollection licenses ;
90101
91102 /**
92103 * Component's copyright
93104 */
105+ @ JsonProperty ("copyright" )
94106 private final String copyright ;
95107
96108 /**
97109 * Component's hashes
98110 */
111+ @ JsonProperty ("hashes" )
112+ @ JsonSerialize (using = CDX14HashesSerializer .class )
99113 private final Map <String , String > hashes ;
100114
101115 /**
102116 * Component's supplier
103117 */
118+ @ JsonProperty ("supplier" )
104119 private final Organization supplier ;
105120
106121 /**
107122 * Component's version
108123 */
124+ @ JsonProperty ("version" )
109125 private final String version ;
110126
111127 /**
112128 * Component's description
113129 */
130+ @ JsonProperty ("description" )
131+ @ JsonSerialize (using = CDX14DescriptionSerializer .class )
114132 private final Description description ;
115133
116134 /**
117135 * Component's CPEs
118136 */
137+ @ JsonIgnore
119138 private final Set <String > cpes ;
120139
121140 /**
122141 * Component's PURLs
123142 */
143+ @ JsonIgnore
124144 private final Set <String > purls ;
125145
126146 /**
127147 * Component's mime type
128148 */
149+ @ JsonProperty ("mime-type" )
129150 private final String mimeType ;
130151
131152 /**
132153 * Component's publisher
133154 */
155+ @ JsonProperty ("publisher" )
134156 private final String publisher ;
135157
136158 /**
137159 * Component's scope
138160 */
161+ @ JsonProperty ("scope" )
139162 private final String scope ;
140163
141164 /**
142165 * Component's group
143166 */
167+ @ JsonProperty ("group" )
144168 private final String group ;
145169
146170 /**
147171 * Component's external references
148172 */
173+ @ JsonProperty ("externalReferences" )
149174 private final Set <ExternalReference > externalReferences ;
150175
151176 /**
152177 * Component's properties
153178 */
154- private final HashMap <String , Set <String >> properties ;
179+ @ JsonProperty ("properties" )
180+ @ JacksonXmlProperty (localName = "properties" )
181+ @ JsonSerialize (using = CDX14PropertiesSerializer .class )
182+ private final Map <String , Set <String >> properties ;
155183
156184 /**
157185 * Constructor to build a new CDX 1.4 Component Object
@@ -209,7 +237,6 @@ public CDX14ComponentObject(String type, String uid, String author, String name,
209237 * @return the component's type
210238 */
211239 @ Override
212- @ JsonProperty ("type" )
213240 public String getType () {
214241 return this .type ;
215242 }
@@ -220,7 +247,6 @@ public String getType() {
220247 * @return the component's uid
221248 */
222249 @ Override
223- @ JsonProperty ("bom-ref" )
224250 public String getUID () {
225251 return this .uid ;
226252 }
@@ -231,7 +257,7 @@ public String getUID() {
231257 * @return the component's author
232258 */
233259 @ Override
234- @ JsonProperty ( "author" )
260+
235261 public String getAuthor () {
236262 return this .author ;
237263 }
@@ -242,7 +268,6 @@ public String getAuthor() {
242268 * @return the component's name
243269 */
244270 @ Override
245- @ JsonProperty ("name" )
246271 public String getName () {
247272 return this .name ;
248273 }
@@ -253,8 +278,6 @@ public String getName() {
253278 * @return the component's licenses
254279 */
255280 @ Override
256- @ JsonProperty ("licenses" )
257- @ JsonSerialize (using = CDX14LicenseCollectionSerializer .class )
258281 public LicenseCollection getLicenses () {
259282 return this .licenses ;
260283 }
@@ -265,7 +288,6 @@ public LicenseCollection getLicenses() {
265288 * @return the component's copyright info
266289 */
267290 @ Override
268- @ JsonProperty ("copyright" )
269291 public String getCopyright () {
270292 return this .copyright ;
271293 }
@@ -276,8 +298,6 @@ public String getCopyright() {
276298 * @return the component's hashes
277299 */
278300 @ Override
279- @ JsonProperty ("hashes" )
280- @ JsonSerialize (using = CDX14HashesSerializer .class )
281301 public Map <String , String > getHashes () {
282302 return this .hashes ;
283303 }
@@ -288,7 +308,6 @@ public Map<String, String> getHashes() {
288308 * @return The component's supplier
289309 */
290310 @ Override
291- @ JsonProperty ("supplier" )
292311 public Organization getSupplier () {
293312 return this .supplier ;
294313 }
@@ -299,7 +318,6 @@ public Organization getSupplier() {
299318 * @return the component's version
300319 */
301320 @ Override
302- @ JsonProperty ("version" )
303321 public String getVersion () {
304322 return this .version ;
305323 }
@@ -310,8 +328,6 @@ public String getVersion() {
310328 * @return the component's description
311329 */
312330 @ Override
313- @ JsonProperty ("description" )
314- @ JsonSerialize (using = CDX14DescriptionSerializer .class )
315331 public Description getDescription () {
316332 return this .description ;
317333 }
@@ -322,7 +338,6 @@ public Description getDescription() {
322338 * @return the component's CPEs
323339 */
324340 @ Override
325- @ JsonIgnore
326341 public Set <String > getCPEs () {
327342 return this .cpes ;
328343 }
@@ -333,7 +348,6 @@ public Set<String> getCPEs() {
333348 * @return the component's PURLs
334349 */
335350 @ Override
336- @ JsonIgnore
337351 public Set <String > getPURLs () {
338352 return this .purls ;
339353 }
@@ -344,7 +358,6 @@ public Set<String> getPURLs() {
344358 * @return the component's external references
345359 */
346360 @ Override
347- @ JsonProperty ("externalReferences" )
348361 public Set <ExternalReference > getExternalReferences () {
349362 return this .externalReferences ;
350363 }
@@ -355,7 +368,6 @@ public Set<ExternalReference> getExternalReferences() {
355368 * @return the component's mime type
356369 */
357370 @ Override
358- @ JsonProperty ("mime-type" )
359371 public String getMimeType () {
360372 return this .mimeType ;
361373 }
@@ -366,7 +378,6 @@ public String getMimeType() {
366378 * @return the component's publisher
367379 */
368380 @ Override
369- @ JsonProperty ("publisher" )
370381 public String getPublisher () {
371382 return this .publisher ;
372383 }
@@ -377,7 +388,6 @@ public String getPublisher() {
377388 * @return the component's scope
378389 */
379390 @ Override
380- @ JsonProperty ("scope" )
381391 public String getScope () {
382392 return this .scope ;
383393 }
@@ -388,7 +398,6 @@ public String getScope() {
388398 * @return the component's group
389399 */
390400 @ Override
391- @ JsonProperty ("group" )
392401 public String getGroup () {
393402 return this .group ;
394403 }
@@ -399,9 +408,7 @@ public String getGroup() {
399408 * @return the component's properties
400409 */
401410 @ Override
402- @ JsonProperty ("properties" )
403- @ JsonSerialize (using = CDX14PropertiesSerializer .class )
404- public HashMap <String , Set <String >> getProperties () {
411+ public Map <String , Set <String >> getProperties () {
405412 return this .properties ;
406413 }
407414
0 commit comments