View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
4   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
5   import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
6   import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
7   import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
8   import java.lang.Override;
9   import java.lang.String;
10  import java.util.LinkedList;
11  import java.util.List;
12  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
13  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
14  
15  /**
16   * Identifies the source of the finding, such as a tool, interviewed person, or activity.
17   */
18  @MetaschemaAssembly(
19      formalName = "Origin",
20      description = "Identifies the source of the finding, such as a tool, interviewed person, or activity.",
21      name = "origin",
22      metaschema = OscalAssessmentCommonMetaschema.class
23  )
24  public class Origin {
25    @BoundAssembly(
26        formalName = "Originating Actor",
27        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.",
28        useName = "actor",
29        minOccurs = 1,
30        maxOccurs = -1
31    )
32    @GroupAs(
33        name = "actors",
34        inJson = JsonGroupAsBehavior.LIST
35    )
36    private List<OriginActor> _actors;
37  
38    @BoundAssembly(
39        formalName = "Task Reference",
40        description = "Identifies an individual task for which the containing object is a consequence of.",
41        useName = "related-task",
42        maxOccurs = -1
43    )
44    @GroupAs(
45        name = "related-tasks",
46        inJson = JsonGroupAsBehavior.LIST
47    )
48    private List<RelatedTask> _relatedTasks;
49  
50    public Origin() {
51    }
52  
53    public List<OriginActor> getActors() {
54      return _actors;
55    }
56  
57    public void setActors(List<OriginActor> value) {
58      _actors = value;
59    }
60  
61    /**
62     * Add a new {@link OriginActor} item to the underlying collection.
63     * @param item the item to add
64     * @return {@code true}
65     */
66    public boolean addActor(OriginActor item) {
67      OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
68      if (_actors == null) {
69        _actors = new LinkedList<>();
70      }
71      return _actors.add(value);
72    }
73  
74    /**
75     * Remove the first matching {@link OriginActor} item from the underlying collection.
76     * @param item the item to remove
77     * @return {@code true} if the item was removed or {@code false} otherwise
78     */
79    public boolean removeActor(OriginActor item) {
80      OriginActor value = ObjectUtils.requireNonNull(item,"item cannot be null");
81      return _actors == null ? false : _actors.remove(value);
82    }
83  
84    public List<RelatedTask> getRelatedTasks() {
85      return _relatedTasks;
86    }
87  
88    public void setRelatedTasks(List<RelatedTask> value) {
89      _relatedTasks = value;
90    }
91  
92    /**
93     * Add a new {@link RelatedTask} item to the underlying collection.
94     * @param item the item to add
95     * @return {@code true}
96     */
97    public boolean addRelatedTask(RelatedTask item) {
98      RelatedTask value = ObjectUtils.requireNonNull(item,"item cannot be null");
99      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 }