View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
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.GroupAs;
8   import gov.nist.secauto.metaschema.binding.model.annotations.Index;
9   import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
10  import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
11  import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
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.markup.MarkupMultiline;
15  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
16  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
17  import java.lang.Override;
18  import java.lang.String;
19  import java.util.LinkedList;
20  import java.util.List;
21  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
22  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
23  
24  /**
25   * Describes how the system satisfies a set of controls.
26   */
27  @MetaschemaAssembly(
28      formalName = "Control Implementation",
29      description = "Describes how the system satisfies a set of controls.",
30      name = "control-implementation",
31      metaschema = OscalSspMetaschema.class,
32      remarks = "Use of `set-parameter` in this context, sets the parameter for all controls referenced by any `implemented-requirement` contained in this context. Any `set-parameter` defined in a child context will override this value. If not overridden by a child, this value applies in the child context."
33  )
34  @AssemblyConstraints(
35      index = @Index(level = IConstraint.Level.ERROR, target = "implemented-requirement//by-component/export/provided", name = "by-component-export-provided-uuid", keyFields = @KeyField(target = "@uuid")),
36      isUnique = @IsUnique(id = "unique-ssp-control-implementation-set-parameter", level = IConstraint.Level.ERROR, target = "set-parameter", keyFields = @KeyField(target = "@param-id"), remarks = "Since multiple `set-parameter` entries can be provided, each parameter must be set only once.")
37  )
38  public class ControlImplementation {
39    /**
40     * "A statement describing important things to know about how this set of control satisfaction documentation is approached."
41     */
42    @BoundField(
43        formalName = "Control Implementation Description",
44        description = "A statement describing important things to know about how this set of control satisfaction documentation is approached.",
45        useName = "description",
46        minOccurs = 1
47    )
48    @BoundFieldValue(
49        typeAdapter = MarkupMultilineAdapter.class
50    )
51    private MarkupMultiline _description;
52  
53    @BoundAssembly(
54        formalName = "Set Parameter Value",
55        description = "Identifies the parameter that will be set by the enclosed value.",
56        useName = "set-parameter",
57        maxOccurs = -1
58    )
59    @GroupAs(
60        name = "set-parameters",
61        inJson = JsonGroupAsBehavior.LIST
62    )
63    private List<SetParameter> _setParameters;
64  
65    @BoundAssembly(
66        formalName = "Control-based Requirement",
67        description = "Describes how the system satisfies the requirements of an individual control.",
68        useName = "implemented-requirement",
69        minOccurs = 1,
70        maxOccurs = -1
71    )
72    @GroupAs(
73        name = "implemented-requirements",
74        inJson = JsonGroupAsBehavior.LIST
75    )
76    private List<ImplementedRequirement> _implementedRequirements;
77  
78    public ControlImplementation() {
79    }
80  
81    public MarkupMultiline getDescription() {
82      return _description;
83    }
84  
85    public void setDescription(MarkupMultiline value) {
86      _description = value;
87    }
88  
89    public List<SetParameter> getSetParameters() {
90      return _setParameters;
91    }
92  
93    public void setSetParameters(List<SetParameter> value) {
94      _setParameters = value;
95    }
96  
97    /**
98     * Add a new {@link SetParameter} item to the underlying collection.
99     * @param item the item to add
100    * @return {@code true}
101    */
102   public boolean addSetParameter(SetParameter item) {
103     SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
104     if (_setParameters == null) {
105       _setParameters = new LinkedList<>();
106     }
107     return _setParameters.add(value);
108   }
109 
110   /**
111    * Remove the first matching {@link SetParameter} item from the underlying collection.
112    * @param item the item to remove
113    * @return {@code true} if the item was removed or {@code false} otherwise
114    */
115   public boolean removeSetParameter(SetParameter item) {
116     SetParameter value = ObjectUtils.requireNonNull(item,"item cannot be null");
117     return _setParameters == null ? false : _setParameters.remove(value);
118   }
119 
120   public List<ImplementedRequirement> getImplementedRequirements() {
121     return _implementedRequirements;
122   }
123 
124   public void setImplementedRequirements(List<ImplementedRequirement> value) {
125     _implementedRequirements = value;
126   }
127 
128   /**
129    * Add a new {@link ImplementedRequirement} item to the underlying collection.
130    * @param item the item to add
131    * @return {@code true}
132    */
133   public boolean addImplementedRequirement(ImplementedRequirement item) {
134     ImplementedRequirement value = ObjectUtils.requireNonNull(item,"item cannot be null");
135     if (_implementedRequirements == null) {
136       _implementedRequirements = new LinkedList<>();
137     }
138     return _implementedRequirements.add(value);
139   }
140 
141   /**
142    * Remove the first matching {@link ImplementedRequirement} item from the underlying collection.
143    * @param item the item to remove
144    * @return {@code true} if the item was removed or {@code false} otherwise
145    */
146   public boolean removeImplementedRequirement(ImplementedRequirement item) {
147     ImplementedRequirement value = ObjectUtils.requireNonNull(item,"item cannot be null");
148     return _implementedRequirements == null ? false : _implementedRequirements.remove(value);
149   }
150 
151   @Override
152   public String toString() {
153     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
154   }
155 }