Skip to content

Commit 66fcb64

Browse files
authored
Merge pull request #578 from CycloneDX/Add_util_methods
2 parents 4fbdc6b + 83b9e3f commit 66fcb64

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/main/java/org/cyclonedx/model/Evidence.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ public void setOccurrences(final List<Occurrence> occurrences) {
108108
this.occurrences = occurrences;
109109
}
110110

111+
public void addOccurrence(Occurrence occurrence) {
112+
if (this.occurrences == null) {
113+
this.occurrences = new ArrayList<>();
114+
}
115+
this.occurrences.add(occurrence);
116+
}
117+
111118
public Callstack getCallstack() {
112119
return callstack;
113120
}

src/main/java/org/cyclonedx/model/Property.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public class Property extends ExtensibleElement {
4141
@JacksonXmlText
4242
private String value;
4343

44+
public Property() {
45+
}
46+
public Property(String name, String value) {
47+
this.name = name;
48+
this.value = value;
49+
}
50+
4451
public String getName() {
4552
return name;
4653
}

src/main/java/org/cyclonedx/model/vulnerability/Vulnerability.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
3232
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
3333
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
34-
import org.cyclonedx.Version;
3534
import org.cyclonedx.model.OrganizationalContact;
3635
import org.cyclonedx.model.OrganizationalEntity;
3736
import org.cyclonedx.model.Property;
@@ -151,6 +150,13 @@ public void setReferences(final List<Reference> references) {
151150
this.references = references;
152151
}
153152

153+
private void addReference(Reference reference) {
154+
if (references == null) {
155+
references = new ArrayList<>();
156+
}
157+
references.add(reference);
158+
}
159+
154160
@JacksonXmlElementWrapper(localName = "ratings")
155161
@JacksonXmlProperty(localName = "rating")
156162
public List<Rating> getRatings() {
@@ -296,6 +302,13 @@ public void setAffects(final List<Affect> affects) {
296302
this.affects = affects;
297303
}
298304

305+
private void addAffect(Affect affect) {
306+
if (affects == null) {
307+
affects = new ArrayList<>();
308+
}
309+
affects.add(affect);
310+
}
311+
299312
@JacksonXmlElementWrapper(localName = "properties")
300313
@JacksonXmlProperty(localName = "property")
301314
public List<Property> getProperties() {
@@ -306,6 +319,13 @@ public void setProperties(final List<Property> properties) {
306319
this.properties = properties;
307320
}
308321

322+
private void addProperty(Property property) {
323+
if (properties == null) {
324+
properties = new ArrayList<>();
325+
}
326+
properties.add(property);
327+
}
328+
309329
public String getWorkaround() {
310330
return workaround;
311331
}

0 commit comments

Comments
 (0)