Skip to content

Commit

Permalink
Merge pull request #578 from CycloneDX/Add_util_methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nscuro authored Dec 21, 2024
2 parents 4fbdc6b + 83b9e3f commit 66fcb64
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/org/cyclonedx/model/Evidence.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ public void setOccurrences(final List<Occurrence> occurrences) {
this.occurrences = occurrences;
}

public void addOccurrence(Occurrence occurrence) {
if (this.occurrences == null) {
this.occurrences = new ArrayList<>();
}
this.occurrences.add(occurrence);
}

public Callstack getCallstack() {
return callstack;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/cyclonedx/model/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public class Property extends ExtensibleElement {
@JacksonXmlText
private String value;

public Property() {
}
public Property(String name, String value) {
this.name = name;
this.value = value;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.Version;
import org.cyclonedx.model.OrganizationalContact;
import org.cyclonedx.model.OrganizationalEntity;
import org.cyclonedx.model.Property;
Expand Down Expand Up @@ -151,6 +150,13 @@ public void setReferences(final List<Reference> references) {
this.references = references;
}

private void addReference(Reference reference) {
if (references == null) {
references = new ArrayList<>();
}
references.add(reference);
}

@JacksonXmlElementWrapper(localName = "ratings")
@JacksonXmlProperty(localName = "rating")
public List<Rating> getRatings() {
Expand Down Expand Up @@ -296,6 +302,13 @@ public void setAffects(final List<Affect> affects) {
this.affects = affects;
}

private void addAffect(Affect affect) {
if (affects == null) {
affects = new ArrayList<>();
}
affects.add(affect);
}

@JacksonXmlElementWrapper(localName = "properties")
@JacksonXmlProperty(localName = "property")
public List<Property> getProperties() {
Expand All @@ -306,6 +319,13 @@ public void setProperties(final List<Property> properties) {
this.properties = properties;
}

private void addProperty(Property property) {
if (properties == null) {
properties = new ArrayList<>();
}
properties.add(property);
}

public String getWorkaround() {
return workaround;
}
Expand Down

0 comments on commit 66fcb64

Please sign in to comment.