001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue; 004import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 006import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 007import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 008import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag; 009import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 010import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 011import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints; 012import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 013import gov.nist.secauto.metaschema.model.common.constraint.IConstraint; 014import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter; 015import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter; 016import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 017import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 018import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 019import java.lang.Override; 020import java.lang.String; 021import java.util.LinkedList; 022import java.util.List; 023import java.util.UUID; 024import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 025import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 026 027/** 028 * Identifies a set of assessment subjects to include/exclude by UUID. 029 */ 030@MetaschemaAssembly( 031 formalName = "Select Assessment Subject", 032 description = "Identifies a set of assessment subjects to include/exclude by UUID.", 033 name = "select-subject-by-id", 034 metaschema = OscalAssessmentCommonMetaschema.class 035) 036public class SelectSubjectById { 037 @BoundFlag( 038 formalName = "Subject Universally Unique Identifier Reference", 039 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.", 040 useName = "subject-uuid", 041 required = true, 042 typeAdapter = UuidAdapter.class 043 ) 044 private UUID _subjectUuid; 045 046 @BoundFlag( 047 formalName = "Subject Universally Unique Identifier Reference Type", 048 description = "Used to indicate the type of object pointed to by the `uuid-ref` within a subject.", 049 useName = "type", 050 required = true, 051 typeAdapter = TokenAdapter.class 052 ) 053 @ValueConstraints( 054 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")}) 055 ) 056 private String _type; 057 058 @BoundAssembly( 059 formalName = "Property", 060 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 061 useName = "prop", 062 maxOccurs = -1 063 ) 064 @GroupAs( 065 name = "props", 066 inJson = JsonGroupAsBehavior.LIST 067 ) 068 private List<Property> _props; 069 070 @BoundAssembly( 071 formalName = "Link", 072 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 073 useName = "link", 074 maxOccurs = -1 075 ) 076 @GroupAs( 077 name = "links", 078 inJson = JsonGroupAsBehavior.LIST 079 ) 080 private List<Link> _links; 081 082 @BoundField( 083 formalName = "Remarks", 084 description = "Additional commentary about the containing object.", 085 useName = "remarks" 086 ) 087 @BoundFieldValue( 088 typeAdapter = MarkupMultilineAdapter.class 089 ) 090 private MarkupMultiline _remarks; 091 092 public SelectSubjectById() { 093 } 094 095 public UUID getSubjectUuid() { 096 return _subjectUuid; 097 } 098 099 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}