OriginActor.java

  1. package gov.nist.secauto.oscal.lib.model;

  2. import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
  3. import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
  4. import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
  5. import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
  6. import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
  7. import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
  8. import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
  9. import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
  10. import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
  11. import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
  12. import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
  13. import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
  14. import java.lang.Override;
  15. import java.lang.String;
  16. import java.util.LinkedList;
  17. import java.util.List;
  18. import java.util.UUID;
  19. import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
  20. import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

  21. /**
  22.  * 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.
  23.  */
  24. @MetaschemaAssembly(
  25.     formalName = "Originating Actor",
  26.     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.",
  27.     name = "origin-actor",
  28.     metaschema = OscalAssessmentCommonMetaschema.class
  29. )
  30. public class OriginActor {
  31.   @BoundFlag(
  32.       formalName = "Actor Type",
  33.       description = "The kind of actor.",
  34.       useName = "type",
  35.       required = true,
  36.       typeAdapter = TokenAdapter.class
  37.   )
  38.   @ValueConstraints(
  39.       allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "tool", description = "A reference to a tool component defined with the assessment assets."), @AllowedValue(value = "assessment-platform", description = "A reference to an assessment-platform defined with the assessment assets."), @AllowedValue(value = "party", description = "A reference to a party defined within the document metadata.")})
  40.   )
  41.   private String _type;

  42.   @BoundFlag(
  43.       formalName = "Actor Universally Unique Identifier Reference",
  44.       description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to the tool or person based on the associated type.",
  45.       useName = "actor-uuid",
  46.       required = true,
  47.       typeAdapter = UuidAdapter.class
  48.   )
  49.   private UUID _actorUuid;

  50.   @BoundFlag(
  51.       formalName = "Actor Role",
  52.       description = "For a party, this can optionally be used to specify the role the actor was performing.",
  53.       useName = "role-id",
  54.       typeAdapter = TokenAdapter.class
  55.   )
  56.   private String _roleId;

  57.   @BoundAssembly(
  58.       formalName = "Property",
  59.       description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
  60.       useName = "prop",
  61.       maxOccurs = -1
  62.   )
  63.   @GroupAs(
  64.       name = "props",
  65.       inJson = JsonGroupAsBehavior.LIST
  66.   )
  67.   private List<Property> _props;

  68.   @BoundAssembly(
  69.       formalName = "Link",
  70.       description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
  71.       useName = "link",
  72.       maxOccurs = -1
  73.   )
  74.   @GroupAs(
  75.       name = "links",
  76.       inJson = JsonGroupAsBehavior.LIST
  77.   )
  78.   private List<Link> _links;

  79.   public OriginActor() {
  80.   }

  81.   public String getType() {
  82.     return _type;
  83.   }

  84.   public void setType(String value) {
  85.     _type = value;
  86.   }

  87.   public UUID getActorUuid() {
  88.     return _actorUuid;
  89.   }

  90.   public void setActorUuid(UUID value) {
  91.     _actorUuid = value;
  92.   }

  93.   public String getRoleId() {
  94.     return _roleId;
  95.   }

  96.   public void setRoleId(String value) {
  97.     _roleId = value;
  98.   }

  99.   public List<Property> getProps() {
  100.     return _props;
  101.   }

  102.   public void setProps(List<Property> value) {
  103.     _props = value;
  104.   }

  105.   /**
  106.    * Add a new {@link Property} item to the underlying collection.
  107.    * @param item the item to add
  108.    * @return {@code true}
  109.    */
  110.   public boolean addProp(Property item) {
  111.     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
  112.     if (_props == null) {
  113.       _props = new LinkedList<>();
  114.     }
  115.     return _props.add(value);
  116.   }

  117.   /**
  118.    * Remove the first matching {@link Property} item from the underlying collection.
  119.    * @param item the item to remove
  120.    * @return {@code true} if the item was removed or {@code false} otherwise
  121.    */
  122.   public boolean removeProp(Property item) {
  123.     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
  124.     return _props == null ? false : _props.remove(value);
  125.   }

  126.   public List<Link> getLinks() {
  127.     return _links;
  128.   }

  129.   public void setLinks(List<Link> value) {
  130.     _links = value;
  131.   }

  132.   /**
  133.    * Add a new {@link Link} item to the underlying collection.
  134.    * @param item the item to add
  135.    * @return {@code true}
  136.    */
  137.   public boolean addLink(Link item) {
  138.     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
  139.     if (_links == null) {
  140.       _links = new LinkedList<>();
  141.     }
  142.     return _links.add(value);
  143.   }

  144.   /**
  145.    * Remove the first matching {@link Link} item from the underlying collection.
  146.    * @param item the item to remove
  147.    * @return {@code true} if the item was removed or {@code false} otherwise
  148.    */
  149.   public boolean removeLink(Link item) {
  150.     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
  151.     return _links == null ? false : _links.remove(value);
  152.   }

  153.   @Override
  154.   public String toString() {
  155.     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
  156.   }
  157. }