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.BoundField;
005import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
006import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
007import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
008import gov.nist.secauto.metaschema.binding.model.annotations.IndexHasKey;
009import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
010import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
011import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
012import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
013import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
014import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
015import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
016import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
017import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
018import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
019import java.lang.Override;
020import java.lang.String;
021import java.util.LinkedList;
022import java.util.List;
023import java.util.UUID;
024import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
025import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
026
027/**
028 * 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.
029 */
030@MetaschemaAssembly(
031    formalName = "Responsible Role",
032    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.",
033    name = "responsible-role",
034    metaschema = OscalMetadataMetaschema.class,
035    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"
036            + "\n"
037            + "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."
038)
039public class ResponsibleRole {
040  @BoundFlag(
041      formalName = "Responsible Role ID",
042      description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) identifier reference to a `role` performed.",
043      useName = "role-id",
044      required = true,
045      typeAdapter = TokenAdapter.class
046  )
047  private String _roleId;
048
049  @BoundAssembly(
050      formalName = "Property",
051      description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
052      useName = "prop",
053      maxOccurs = -1
054  )
055  @GroupAs(
056      name = "props",
057      inJson = JsonGroupAsBehavior.LIST
058  )
059  private List<Property> _props;
060
061  @BoundAssembly(
062      formalName = "Link",
063      description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
064      useName = "link",
065      maxOccurs = -1
066  )
067  @GroupAs(
068      name = "links",
069      inJson = JsonGroupAsBehavior.LIST
070  )
071  private List<Link> _links;
072
073  /**
074   * "Specifies zero or more parties responsible for performing the associated <code>role</code>."
075   */
076  @BoundField(
077      formalName = "Party Universally Unique Identifier Reference",
078      description = "Specifies zero or more parties responsible for performing the associated `role`.",
079      useName = "party-uuid",
080      maxOccurs = -1
081  )
082  @BoundFieldValue(
083      typeAdapter = UuidAdapter.class
084  )
085  @ValueConstraints(
086      indexHasKey = @IndexHasKey(level = IConstraint.Level.ERROR, indexName = "index-metadata-party-uuid", keyFields = @KeyField)
087  )
088  @GroupAs(
089      name = "party-uuids",
090      inJson = JsonGroupAsBehavior.LIST
091  )
092  private List<UUID> _partyUuids;
093
094  @BoundField(
095      formalName = "Remarks",
096      description = "Additional commentary about the containing object.",
097      useName = "remarks"
098  )
099  @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}