View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
4   import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
5   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
6   import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
7   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
8   import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
9   import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
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   * Identifies a set of assessment subjects to include/exclude by UUID.
29   */
30  @MetaschemaAssembly(
31      formalName = "Select Assessment Subject",
32      description = "Identifies a set of assessment subjects to include/exclude by UUID.",
33      name = "select-subject-by-id",
34      metaschema = OscalAssessmentCommonMetaschema.class
35  )
36  public class SelectSubjectById {
37    @BoundFlag(
38        formalName = "Subject Universally Unique Identifier Reference",
39        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.",
40        useName = "subject-uuid",
41        required = true,
42        typeAdapter = UuidAdapter.class
43    )
44    private UUID _subjectUuid;
45  
46    @BoundFlag(
47        formalName = "Subject Universally Unique Identifier Reference Type",
48        description = "Used to indicate the type of object pointed to by the `uuid-ref` within a subject.",
49        useName = "type",
50        required = true,
51        typeAdapter = TokenAdapter.class
52    )
53    @ValueConstraints(
54        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")})
55    )
56    private String _type;
57  
58    @BoundAssembly(
59        formalName = "Property",
60        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
61        useName = "prop",
62        maxOccurs = -1
63    )
64    @GroupAs(
65        name = "props",
66        inJson = JsonGroupAsBehavior.LIST
67    )
68    private List<Property> _props;
69  
70    @BoundAssembly(
71        formalName = "Link",
72        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
73        useName = "link",
74        maxOccurs = -1
75    )
76    @GroupAs(
77        name = "links",
78        inJson = JsonGroupAsBehavior.LIST
79    )
80    private List<Link> _links;
81  
82    @BoundField(
83        formalName = "Remarks",
84        description = "Additional commentary about the containing object.",
85        useName = "remarks"
86    )
87    @BoundFieldValue(
88        typeAdapter = MarkupMultilineAdapter.class
89    )
90    private MarkupMultiline _remarks;
91  
92    public SelectSubjectById() {
93    }
94  
95    public UUID getSubjectUuid() {
96      return _subjectUuid;
97    }
98  
99    public void setSubjectUuid(UUID value) {
100     _subjectUuid = value;
101   }
102 
103   public String getType() {
104     return _type;
105   }
106 
107   public void setType(String value) {
108     _type = value;
109   }
110 
111   public List<Property> getProps() {
112     return _props;
113   }
114 
115   public void setProps(List<Property> value) {
116     _props = value;
117   }
118 
119   /**
120    * Add a new {@link Property} item to the underlying collection.
121    * @param item the item to add
122    * @return {@code true}
123    */
124   public boolean addProp(Property item) {
125     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
126     if (_props == null) {
127       _props = new LinkedList<>();
128     }
129     return _props.add(value);
130   }
131 
132   /**
133    * Remove the first matching {@link Property} item from the underlying collection.
134    * @param item the item to remove
135    * @return {@code true} if the item was removed or {@code false} otherwise
136    */
137   public boolean removeProp(Property item) {
138     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
139     return _props == null ? false : _props.remove(value);
140   }
141 
142   public List<Link> getLinks() {
143     return _links;
144   }
145 
146   public void setLinks(List<Link> value) {
147     _links = value;
148   }
149 
150   /**
151    * Add a new {@link Link} item to the underlying collection.
152    * @param item the item to add
153    * @return {@code true}
154    */
155   public boolean addLink(Link item) {
156     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
157     if (_links == null) {
158       _links = new LinkedList<>();
159     }
160     return _links.add(value);
161   }
162 
163   /**
164    * Remove the first matching {@link Link} item from the underlying collection.
165    * @param item the item to remove
166    * @return {@code true} if the item was removed or {@code false} otherwise
167    */
168   public boolean removeLink(Link item) {
169     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
170     return _links == null ? false : _links.remove(value);
171   }
172 
173   public MarkupMultiline getRemarks() {
174     return _remarks;
175   }
176 
177   public void setRemarks(MarkupMultiline value) {
178     _remarks = value;
179   }
180 
181   @Override
182   public String toString() {
183     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
184   }
185 }