001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 004import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 005import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 006import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 007import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 008import java.lang.Override; 009import java.lang.String; 010import java.util.LinkedList; 011import java.util.List; 012import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 013import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 014 015/** 016 * Identifies the source of the finding, such as a tool, interviewed person, or activity. 017 */ 018@MetaschemaAssembly( 019 formalName = "Origin", 020 description = "Identifies the source of the finding, such as a tool, interviewed person, or activity.", 021 name = "origin", 022 metaschema = OscalAssessmentCommonMetaschema.class 023) 024public class Origin { 025 @BoundAssembly( 026 formalName = "Originating Actor", 027 description = "The actor that produces an observation, a finding, or a risk. One or more actor type can be used to specify a person that is using a tool.", 028 useName = "actor", 029 minOccurs = 1, 030 maxOccurs = -1 031 ) 032 @GroupAs( 033 name = "actors", 034 inJson = JsonGroupAsBehavior.LIST 035 ) 036 private List<OriginActor> _actors; 037 038 @BoundAssembly( 039 formalName = "Task Reference", 040 description = "Identifies an individual task for which the containing object is a consequence of.", 041 useName = "related-task", 042 maxOccurs = -1 043 ) 044 @GroupAs( 045 name = "related-tasks", 046 inJson = JsonGroupAsBehavior.LIST 047 ) 048 private List<RelatedTask> _relatedTasks; 049 050 public Origin() { 051 } 052 053 public List<OriginActor> getActors() { 054 return _actors; 055 } 056 057 public void setActors(List<OriginActor> value) { 058 _actors = value; 059 } 060 061 /** 062 * Add a new {@link OriginActor} item to the underlying collection. 063 * @param item the item to add 064 * @return {@code true} 065 */ 066 public boolean addActor(OriginActor item) { 067 OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null"); 068 if (_actors == null) { 069 _actors = new LinkedList<>(); 070 } 071 return _actors.add(value); 072 } 073 074 /** 075 * Remove the first matching {@link OriginActor} item from the underlying collection. 076 * @param item the item to remove 077 * @return {@code true} if the item was removed or {@code false} otherwise 078 */ 079 public boolean removeActor(OriginActor item) { 080 OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null"); 081 return _actors == null ? false : _actors.remove(value); 082 } 083 084 public List<RelatedTask> getRelatedTasks() { 085 return _relatedTasks; 086 } 087 088 public void setRelatedTasks(List<RelatedTask> value) { 089 _relatedTasks = value; 090 } 091 092 /** 093 * Add a new {@link RelatedTask} item to the underlying collection. 094 * @param item the item to add 095 * @return {@code true} 096 */ 097 public boolean addRelatedTask(RelatedTask item) { 098 RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null"); 099 if (_relatedTasks == null) { 100 _relatedTasks = new LinkedList<>(); 101 } 102 return _relatedTasks.add(value); 103 } 104 105 /** 106 * Remove the first matching {@link RelatedTask} item from the underlying collection. 107 * @param item the item to remove 108 * @return {@code true} if the item was removed or {@code false} otherwise 109 */ 110 public boolean removeRelatedTask(RelatedTask item) { 111 RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null"); 112 return _relatedTasks == null ? false : _relatedTasks.remove(value); 113 } 114 115 @Override 116 public String toString() { 117 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 118 } 119}