SelectSubjectById.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.BoundField;
  6. import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
  7. import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
  8. import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
  9. import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
  10. import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
  11. import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
  12. import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
  13. import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
  14. import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter;
  15. import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline;
  16. import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
  17. import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
  18. import java.lang.Override;
  19. import java.lang.String;
  20. import java.util.LinkedList;
  21. import java.util.List;
  22. import java.util.UUID;
  23. import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
  24. import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

  25. /**
  26.  * Identifies a set of assessment subjects to include/exclude by UUID.
  27.  */
  28. @MetaschemaAssembly(
  29.     formalName = "Select Assessment Subject",
  30.     description = "Identifies a set of assessment subjects to include/exclude by UUID.",
  31.     name = "select-subject-by-id",
  32.     metaschema = OscalAssessmentCommonMetaschema.class
  33. )
  34. public class SelectSubjectById {
  35.   @BoundFlag(
  36.       formalName = "Subject Universally Unique Identifier Reference",
  37.       description = "A [machine-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#machine-oriented) identifier reference to a component, inventory-item, location, party, user, or resource using it's UUID.",
  38.       useName = "subject-uuid",
  39.       required = true,
  40.       typeAdapter = UuidAdapter.class
  41.   )
  42.   private UUID _subjectUuid;

  43.   @BoundFlag(
  44.       formalName = "Subject Universally Unique Identifier Reference Type",
  45.       description = "Used to indicate the type of object pointed to by the `uuid-ref` within a subject.",
  46.       useName = "type",
  47.       required = true,
  48.       typeAdapter = TokenAdapter.class
  49.   )
  50.   @ValueConstraints(
  51.       allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "component", description = "Component"), @AllowedValue(value = "inventory-item", description = "Inventory Item"), @AllowedValue(value = "location", description = "Location"), @AllowedValue(value = "party", description = "Interview Party"), @AllowedValue(value = "user", description = "User"), @AllowedValue(value = "resource", description = "Resource or Artifact")})
  52.   )
  53.   private String _type;

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

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

  76.   @BoundField(
  77.       formalName = "Remarks",
  78.       description = "Additional commentary about the containing object.",
  79.       useName = "remarks"
  80.   )
  81.   @BoundFieldValue(
  82.       typeAdapter = MarkupMultilineAdapter.class
  83.   )
  84.   private MarkupMultiline _remarks;

  85.   public SelectSubjectById() {
  86.   }

  87.   public UUID getSubjectUuid() {
  88.     return _subjectUuid;
  89.   }

  90.   public void setSubjectUuid(UUID value) {
  91.     _subjectUuid = value;
  92.   }

  93.   public String getType() {
  94.     return _type;
  95.   }

  96.   public void setType(String value) {
  97.     _type = 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.   public MarkupMultiline getRemarks() {
  154.     return _remarks;
  155.   }

  156.   public void setRemarks(MarkupMultiline value) {
  157.     _remarks = value;
  158.   }

  159.   @Override
  160.   public String toString() {
  161.     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
  162.   }
  163. }