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.BoundField;
5   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
6   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
7   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
8   import gov.nist.secauto.metaschema.binding.model.annotations.IndexHasKey;
9   import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
10  import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
11  import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
12  import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
13  import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
14  import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
15  import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
16  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
17  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
18  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
19  import java.lang.Override;
20  import java.lang.String;
21  import java.util.LinkedList;
22  import java.util.List;
23  import java.util.UUID;
24  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
25  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
26  
27  /**
28   * A reference to a role with responsibility for performing a function relative to the containing object, optionally associated with a set of persons and/or organizations that perform that role.
29   */
30  @MetaschemaAssembly(
31      formalName = "Responsible Role",
32      description = "A reference to a role with responsibility for performing a function relative to the containing object, optionally associated with a set of persons and/or organizations that perform that role.",
33      name = "responsible-role",
34      metaschema = OscalMetadataMetaschema.class,
35      remarks = "A `responsible-role` allows zero or more `party-uuid` references, each of which creates a relationship arc between the referenced `role-id` and the referenced party. This differs in semantics from `responsible-party`, which requires that at least one `party-uuid` is referenced.\n"
36              + "\n"
37              + "The scope of use of this object determines if the responsibility has been performed or will be performed in the future. The containing object will describe the intent."
38  )
39  public class ResponsibleRole {
40    @BoundFlag(
41        formalName = "Responsible Role ID",
42        description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a `role` performed.",
43        useName = "role-id",
44        required = true,
45        typeAdapter = TokenAdapter.class
46    )
47    private String _roleId;
48  
49    @BoundAssembly(
50        formalName = "Property",
51        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
52        useName = "prop",
53        maxOccurs = -1
54    )
55    @GroupAs(
56        name = "props",
57        inJson = JsonGroupAsBehavior.LIST
58    )
59    private List<Property> _props;
60  
61    @BoundAssembly(
62        formalName = "Link",
63        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
64        useName = "link",
65        maxOccurs = -1
66    )
67    @GroupAs(
68        name = "links",
69        inJson = JsonGroupAsBehavior.LIST
70    )
71    private List<Link> _links;
72  
73    /**
74     * "Specifies zero or more parties responsible for performing the associated <code>role</code>."
75     */
76    @BoundField(
77        formalName = "Party Universally Unique Identifier Reference",
78        description = "Specifies zero or more parties responsible for performing the associated `role`.",
79        useName = "party-uuid",
80        maxOccurs = -1
81    )
82    @BoundFieldValue(
83        typeAdapter = UuidAdapter.class
84    )
85    @ValueConstraints(
86        indexHasKey = @IndexHasKey(level = IConstraint.Level.ERROR, indexName = "index-metadata-party-uuid", keyFields = @KeyField)
87    )
88    @GroupAs(
89        name = "party-uuids",
90        inJson = JsonGroupAsBehavior.LIST
91    )
92    private List<UUID> _partyUuids;
93  
94    @BoundField(
95        formalName = "Remarks",
96        description = "Additional commentary about the containing object.",
97        useName = "remarks"
98    )
99    @BoundFieldValue(
100       typeAdapter = MarkupMultilineAdapter.class
101   )
102   private MarkupMultiline _remarks;
103 
104   public ResponsibleRole() {
105   }
106 
107   public String getRoleId() {
108     return _roleId;
109   }
110 
111   public void setRoleId(String value) {
112     _roleId = value;
113   }
114 
115   public List<Property> getProps() {
116     return _props;
117   }
118 
119   public void setProps(List<Property> value) {
120     _props = value;
121   }
122 
123   /**
124    * Add a new {@link Property} item to the underlying collection.
125    * @param item the item to add
126    * @return {@code true}
127    */
128   public boolean addProp(Property item) {
129     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
130     if (_props == null) {
131       _props = new LinkedList<>();
132     }
133     return _props.add(value);
134   }
135 
136   /**
137    * Remove the first matching {@link Property} item from the underlying collection.
138    * @param item the item to remove
139    * @return {@code true} if the item was removed or {@code false} otherwise
140    */
141   public boolean removeProp(Property item) {
142     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
143     return _props == null ? false : _props.remove(value);
144   }
145 
146   public List<Link> getLinks() {
147     return _links;
148   }
149 
150   public void setLinks(List<Link> value) {
151     _links = value;
152   }
153 
154   /**
155    * Add a new {@link Link} item to the underlying collection.
156    * @param item the item to add
157    * @return {@code true}
158    */
159   public boolean addLink(Link item) {
160     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
161     if (_links == null) {
162       _links = new LinkedList<>();
163     }
164     return _links.add(value);
165   }
166 
167   /**
168    * Remove the first matching {@link Link} item from the underlying collection.
169    * @param item the item to remove
170    * @return {@code true} if the item was removed or {@code false} otherwise
171    */
172   public boolean removeLink(Link item) {
173     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
174     return _links == null ? false : _links.remove(value);
175   }
176 
177   public List<UUID> getPartyUuids() {
178     return _partyUuids;
179   }
180 
181   public void setPartyUuids(List<UUID> value) {
182     _partyUuids = value;
183   }
184 
185   /**
186    * Add a new {@link UUID} item to the underlying collection.
187    * @param item the item to add
188    * @return {@code true}
189    */
190   public boolean addPartyUuid(UUID item) {
191     UUID value = ObjectUtils.requireNonNull(item,"item cannot be null");
192     if (_partyUuids == null) {
193       _partyUuids = new LinkedList<>();
194     }
195     return _partyUuids.add(value);
196   }
197 
198   /**
199    * Remove the first matching {@link UUID} item from the underlying collection.
200    * @param item the item to remove
201    * @return {@code true} if the item was removed or {@code false} otherwise
202    */
203   public boolean removePartyUuid(UUID item) {
204     UUID value = ObjectUtils.requireNonNull(item,"item cannot be null");
205     return _partyUuids == null ? false : _partyUuids.remove(value);
206   }
207 
208   public MarkupMultiline getRemarks() {
209     return _remarks;
210   }
211 
212   public void setRemarks(MarkupMultiline value) {
213     _remarks = value;
214   }
215 
216   @Override
217   public String toString() {
218     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
219   }
220 }