001package com.example.metaschema; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.NonNegativeIntegerAdapter; 004import gov.nist.secauto.metaschema.core.datatype.adapter.PositiveIntegerAdapter; 005import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter; 006import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter; 007import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; 008import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter; 009import gov.nist.secauto.metaschema.core.model.IBoundObject; 010import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 011import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 012import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 013import gov.nist.secauto.metaschema.core.util.ObjectUtils; 014import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 015import gov.nist.secauto.metaschema.databind.model.annotations.BoundChoiceGroup; 016import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 017import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 018import gov.nist.secauto.metaschema.databind.model.annotations.BoundGroupedAssembly; 019import gov.nist.secauto.metaschema.databind.model.annotations.Matches; 020import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 021import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 022import java.lang.Object; 023import java.lang.Override; 024import java.lang.String; 025import java.math.BigInteger; 026import java.util.LinkedList; 027import java.util.List; 028import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 029import org.apache.commons.lang3.builder.ToStringStyle; 030 031@MetaschemaAssembly( 032 formalName = "Inline Assembly Definition", 033 name = "inline-define-assembly", 034 moduleClass = MetaschemaModelModule.class 035) 036public class InlineDefineAssembly implements IBoundObject { 037 private final IMetaschemaData __metaschemaData; 038 039 @BoundFlag( 040 formalName = "Inline Assembly Name", 041 name = "name", 042 required = true, 043 typeAdapter = TokenAdapter.class 044 ) 045 private String _name; 046 047 @BoundFlag( 048 formalName = "Inline Assembly Binary Name", 049 name = "index", 050 typeAdapter = PositiveIntegerAdapter.class 051 ) 052 private BigInteger _index; 053 054 @BoundFlag( 055 formalName = "Deprecated Version", 056 name = "deprecated", 057 typeAdapter = StringAdapter.class 058 ) 059 private String _deprecated; 060 061 @BoundFlag( 062 formalName = "Minimum Occurrence", 063 name = "min-occurs", 064 defaultValue = "0", 065 typeAdapter = NonNegativeIntegerAdapter.class 066 ) 067 private BigInteger _minOccurs; 068 069 @BoundFlag( 070 formalName = "Maximum Occurrence", 071 name = "max-occurs", 072 defaultValue = "1", 073 typeAdapter = StringAdapter.class, 074 valueConstraints = @ValueConstraints(matches = @Matches(level = IConstraint.Level.ERROR, pattern = "^[1-9][0-9]*|unbounded$")) 075 ) 076 private String _maxOccurs; 077 078 @BoundField( 079 formalName = "Formal Name", 080 description = "A formal name for the data construct, to be presented in documentation.", 081 useName = "formal-name" 082 ) 083 private String _formalName; 084 085 @BoundField( 086 formalName = "Description", 087 description = "A short description of the data construct's purpose, describing the constructs semantics.", 088 useName = "description", 089 typeAdapter = MarkupLineAdapter.class 090 ) 091 private MarkupLine _description; 092 093 @BoundAssembly( 094 formalName = "Property", 095 useName = "prop", 096 maxOccurs = -1, 097 groupAs = @gov.nist.secauto.metaschema.databind.model.annotations.GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 098 ) 099 private List<Property> _props; 100 101 @BoundAssembly( 102 formalName = "JSON Key", 103 description = "Used in JSON (and similar formats) to identify a flag that will be used as the property name in an object hold a collection of sibling objects. Requires that siblings must never share `json-key` values.", 104 useName = "json-key" 105 ) 106 private JsonKey _jsonKey; 107 108 @BoundAssembly( 109 formalName = "Group As", 110 useName = "group-as" 111 ) 112 private GroupAs _groupAs; 113 114 @BoundChoiceGroup( 115 maxOccurs = -1, 116 assemblies = { 117 @BoundGroupedAssembly(formalName = "Inline Flag Definition", useName = "define-flag", binding = InlineDefineFlag.class), 118 @BoundGroupedAssembly(formalName = "Flag Reference", useName = "flag", binding = FlagReference.class) 119 }, 120 groupAs = @gov.nist.secauto.metaschema.databind.model.annotations.GroupAs(name = "flags", inJson = JsonGroupAsBehavior.LIST) 121 ) 122 private List<Object> _flags; 123 124 @BoundAssembly( 125 useName = "model" 126 ) 127 private AssemblyModel _model; 128 129 @BoundAssembly( 130 useName = "constraint" 131 ) 132 private AssemblyConstraints _constraint; 133 134 @BoundField( 135 formalName = "Remarks", 136 description = "Any explanatory or helpful information to be provided about the remarks parent.", 137 useName = "remarks" 138 ) 139 private Remarks _remarks; 140 141 @BoundAssembly( 142 formalName = "Example", 143 useName = "example", 144 maxOccurs = -1, 145 groupAs = @gov.nist.secauto.metaschema.databind.model.annotations.GroupAs(name = "examples", inJson = JsonGroupAsBehavior.LIST) 146 ) 147 private List<Example> _examples; 148 149 public InlineDefineAssembly() { 150 this(null); 151 } 152 153 public InlineDefineAssembly(IMetaschemaData data) { 154 this.__metaschemaData = data; 155 } 156 157 @Override 158 public IMetaschemaData getMetaschemaData() { 159 return __metaschemaData; 160 } 161 162 public String getName() { 163 return _name; 164 } 165 166 public void setName(String value) { 167 _name = value; 168 } 169 170 public BigInteger getIndex() { 171 return _index; 172 } 173 174 public void setIndex(BigInteger value) { 175 _index = value; 176 } 177 178 public String getDeprecated() { 179 return _deprecated; 180 } 181 182 public void setDeprecated(String value) { 183 _deprecated = value; 184 } 185 186 public BigInteger getMinOccurs() { 187 return _minOccurs; 188 } 189 190 public void setMinOccurs(BigInteger value) { 191 _minOccurs = value; 192 } 193 194 public String getMaxOccurs() { 195 return _maxOccurs; 196 } 197 198 public void setMaxOccurs(String value) { 199 _maxOccurs = value; 200 } 201 202 public String getFormalName() { 203 return _formalName; 204 } 205 206 public void setFormalName(String value) { 207 _formalName = value; 208 } 209 210 public MarkupLine getDescription() { 211 return _description; 212 } 213 214 public void setDescription(MarkupLine value) { 215 _description = value; 216 } 217 218 public List<Property> getProps() { 219 return _props; 220 } 221 222 public void setProps(List<Property> value) { 223 _props = value; 224 } 225 226 /** 227 * Add a new {@link Property} item to the underlying collection. 228 * @param item the item to add 229 * @return {@code true} 230 */ 231 public boolean addProp(Property item) { 232 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 233 if (_props == null) { 234 _props = new LinkedList<>(); 235 } 236 return _props.add(value); 237 } 238 239 /** 240 * Remove the first matching {@link Property} item from the underlying collection. 241 * @param item the item to remove 242 * @return {@code true} if the item was removed or {@code false} otherwise 243 */ 244 public boolean removeProp(Property item) { 245 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 246 return _props != null && _props.remove(value); 247 } 248 249 public JsonKey getJsonKey() { 250 return _jsonKey; 251 } 252 253 public void setJsonKey(JsonKey value) { 254 _jsonKey = value; 255 } 256 257 public GroupAs getGroupAs() { 258 return _groupAs; 259 } 260 261 public void setGroupAs(GroupAs value) { 262 _groupAs = value; 263 } 264 265 public List<Object> getFlags() { 266 return _flags; 267 } 268 269 public void setFlags(List<Object> value) { 270 _flags = value; 271 } 272 273 public AssemblyModel getModel() { 274 return _model; 275 } 276 277 public void setModel(AssemblyModel value) { 278 _model = value; 279 } 280 281 public AssemblyConstraints getConstraint() { 282 return _constraint; 283 } 284 285 public void setConstraint(AssemblyConstraints value) { 286 _constraint = value; 287 } 288 289 public Remarks getRemarks() { 290 return _remarks; 291 } 292 293 public void setRemarks(Remarks value) { 294 _remarks = value; 295 } 296 297 public List<Example> getExamples() { 298 return _examples; 299 } 300 301 public void setExamples(List<Example> value) { 302 _examples = value; 303 } 304 305 /** 306 * Add a new {@link Example} item to the underlying collection. 307 * @param item the item to add 308 * @return {@code true} 309 */ 310 public boolean addExample(Example item) { 311 Example value = ObjectUtils.requireNonNull(item,"item cannot be null"); 312 if (_examples == null) { 313 _examples = new LinkedList<>(); 314 } 315 return _examples.add(value); 316 } 317 318 /** 319 * Remove the first matching {@link Example} item from the underlying collection. 320 * @param item the item to remove 321 * @return {@code true} if the item was removed or {@code false} otherwise 322 */ 323 public boolean removeExample(Example item) { 324 Example value = ObjectUtils.requireNonNull(item,"item cannot be null"); 325 return _examples != null && _examples.remove(value); 326 } 327 328 @Override 329 public String toString() { 330 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 331 } 332}