001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter; 004import gov.nist.secauto.metaschema.core.datatype.adapter.UuidAdapter; 005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultiline; 006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupMultilineAdapter; 007import gov.nist.secauto.metaschema.core.model.IBoundObject; 008import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 009import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 010import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 011import gov.nist.secauto.metaschema.core.util.ObjectUtils; 012import gov.nist.secauto.metaschema.databind.model.annotations.AssemblyConstraints; 013import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 014import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 015import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 016import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 017import gov.nist.secauto.metaschema.databind.model.annotations.IsUnique; 018import gov.nist.secauto.metaschema.databind.model.annotations.KeyField; 019import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 020import java.lang.Override; 021import java.lang.String; 022import java.util.LinkedList; 023import java.util.List; 024import java.util.UUID; 025import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 026import org.apache.commons.lang3.builder.ToStringStyle; 027 028/** 029 * A grouping of other components and/or capabilities. 030 */ 031@MetaschemaAssembly( 032 formalName = "Capability", 033 description = "A grouping of other components and/or capabilities.", 034 name = "capability", 035 moduleClass = OscalComponentDefinitionModule.class, 036 modelConstraints = @AssemblyConstraints(unique = @IsUnique(id = "unique-component-definition-capability-incorporates-component", level = IConstraint.Level.ERROR, target = "incorporates-component", keyFields = @KeyField(target = "@component-uuid"), remarks = "A given `component` must not be referenced more than once within the same `capability`.")) 037) 038public class Capability implements IBoundObject { 039 private final IMetaschemaData __metaschemaData; 040 041 /** 042 * "Provides a globally unique means to identify a given capability." 043 */ 044 @BoundFlag( 045 formalName = "Capability Identifier", 046 description = "Provides a globally unique means to identify a given capability.", 047 name = "uuid", 048 required = true, 049 typeAdapter = UuidAdapter.class 050 ) 051 private UUID _uuid; 052 053 /** 054 * "The capability's human-readable name." 055 */ 056 @BoundFlag( 057 formalName = "Capability Name", 058 description = "The capability's human-readable name.", 059 name = "name", 060 required = true, 061 typeAdapter = StringAdapter.class 062 ) 063 private String _name; 064 065 @BoundField( 066 formalName = "Capability Description", 067 description = "A summary of the capability.", 068 useName = "description", 069 minOccurs = 1, 070 typeAdapter = MarkupMultilineAdapter.class 071 ) 072 private MarkupMultiline _description; 073 074 @BoundAssembly( 075 formalName = "Property", 076 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 077 useName = "prop", 078 maxOccurs = -1, 079 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 080 ) 081 private List<Property> _props; 082 083 @BoundAssembly( 084 formalName = "Link", 085 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 086 useName = "link", 087 maxOccurs = -1, 088 groupAs = @GroupAs(name = "links", inJson = JsonGroupAsBehavior.LIST) 089 ) 090 private List<Link> _links; 091 092 @BoundAssembly( 093 formalName = "Incorporates Component", 094 description = "The collection of components comprising this capability.", 095 useName = "incorporates-component", 096 maxOccurs = -1, 097 groupAs = @GroupAs(name = "incorporates-components", inJson = JsonGroupAsBehavior.LIST) 098 ) 099 private List<IncorporatesComponent> _incorporatesComponents; 100 101 @BoundAssembly( 102 formalName = "Control Implementation Set", 103 description = "Defines how the component or capability supports a set of controls.", 104 useName = "control-implementation", 105 maxOccurs = -1, 106 groupAs = @GroupAs(name = "control-implementations", inJson = JsonGroupAsBehavior.LIST) 107 ) 108 private List<ComponentControlImplementation> _controlImplementations; 109 110 @BoundField( 111 formalName = "Remarks", 112 description = "Additional commentary about the containing object.", 113 useName = "remarks", 114 typeAdapter = MarkupMultilineAdapter.class 115 ) 116 private MarkupMultiline _remarks; 117 118 public Capability() { 119 this(null); 120 } 121 122 public Capability(IMetaschemaData data) { 123 this.__metaschemaData = data; 124 } 125 126 @Override 127 public IMetaschemaData getMetaschemaData() { 128 return __metaschemaData; 129 } 130 131 public UUID getUuid() { 132 return _uuid; 133 } 134 135 public void setUuid(UUID value) { 136 _uuid = value; 137 } 138 139 public String getName() { 140 return _name; 141 } 142 143 public void setName(String value) { 144 _name = value; 145 } 146 147 public MarkupMultiline getDescription() { 148 return _description; 149 } 150 151 public void setDescription(MarkupMultiline value) { 152 _description = value; 153 } 154 155 public List<Property> getProps() { 156 return _props; 157 } 158 159 public void setProps(List<Property> value) { 160 _props = value; 161 } 162 163 /** 164 * Add a new {@link Property} item to the underlying collection. 165 * @param item the item to add 166 * @return {@code true} 167 */ 168 public boolean addProp(Property item) { 169 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 170 if (_props == null) { 171 _props = new LinkedList<>(); 172 } 173 return _props.add(value); 174 } 175 176 /** 177 * Remove the first matching {@link Property} item from the underlying collection. 178 * @param item the item to remove 179 * @return {@code true} if the item was removed or {@code false} otherwise 180 */ 181 public boolean removeProp(Property item) { 182 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 183 return _props != null && _props.remove(value); 184 } 185 186 public List<Link> getLinks() { 187 return _links; 188 } 189 190 public void setLinks(List<Link> value) { 191 _links = value; 192 } 193 194 /** 195 * Add a new {@link Link} item to the underlying collection. 196 * @param item the item to add 197 * @return {@code true} 198 */ 199 public boolean addLink(Link item) { 200 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 201 if (_links == null) { 202 _links = new LinkedList<>(); 203 } 204 return _links.add(value); 205 } 206 207 /** 208 * Remove the first matching {@link Link} item from the underlying collection. 209 * @param item the item to remove 210 * @return {@code true} if the item was removed or {@code false} otherwise 211 */ 212 public boolean removeLink(Link item) { 213 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 214 return _links != null && _links.remove(value); 215 } 216 217 public List<IncorporatesComponent> getIncorporatesComponents() { 218 return _incorporatesComponents; 219 } 220 221 public void setIncorporatesComponents(List<IncorporatesComponent> value) { 222 _incorporatesComponents = value; 223 } 224 225 /** 226 * Add a new {@link IncorporatesComponent} item to the underlying collection. 227 * @param item the item to add 228 * @return {@code true} 229 */ 230 public boolean addIncorporatesComponent(IncorporatesComponent item) { 231 IncorporatesComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 232 if (_incorporatesComponents == null) { 233 _incorporatesComponents = new LinkedList<>(); 234 } 235 return _incorporatesComponents.add(value); 236 } 237 238 /** 239 * Remove the first matching {@link IncorporatesComponent} item from the underlying collection. 240 * @param item the item to remove 241 * @return {@code true} if the item was removed or {@code false} otherwise 242 */ 243 public boolean removeIncorporatesComponent(IncorporatesComponent item) { 244 IncorporatesComponent value = ObjectUtils.requireNonNull(item,"item cannot be null"); 245 return _incorporatesComponents != null && _incorporatesComponents.remove(value); 246 } 247 248 public List<ComponentControlImplementation> getControlImplementations() { 249 return _controlImplementations; 250 } 251 252 public void setControlImplementations(List<ComponentControlImplementation> value) { 253 _controlImplementations = value; 254 } 255 256 /** 257 * Add a new {@link ComponentControlImplementation} item to the underlying collection. 258 * @param item the item to add 259 * @return {@code true} 260 */ 261 public boolean addControlImplementation(ComponentControlImplementation item) { 262 ComponentControlImplementation value = ObjectUtils.requireNonNull(item,"item cannot be null"); 263 if (_controlImplementations == null) { 264 _controlImplementations = new LinkedList<>(); 265 } 266 return _controlImplementations.add(value); 267 } 268 269 /** 270 * Remove the first matching {@link ComponentControlImplementation} item from the underlying collection. 271 * @param item the item to remove 272 * @return {@code true} if the item was removed or {@code false} otherwise 273 */ 274 public boolean removeControlImplementation(ComponentControlImplementation item) { 275 ComponentControlImplementation value = ObjectUtils.requireNonNull(item,"item cannot be null"); 276 return _controlImplementations != null && _controlImplementations.remove(value); 277 } 278 279 public MarkupMultiline getRemarks() { 280 return _remarks; 281 } 282 283 public void setRemarks(MarkupMultiline value) { 284 _remarks = value; 285 } 286 287 @Override 288 public String toString() { 289 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 290 } 291}