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.AllowedValue; 015import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues; 016import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 017import gov.nist.secauto.metaschema.databind.model.annotations.BoundChoiceGroup; 018import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 019import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 020import gov.nist.secauto.metaschema.databind.model.annotations.BoundGroupedAssembly; 021import gov.nist.secauto.metaschema.databind.model.annotations.Matches; 022import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 023import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 024import java.lang.Object; 025import java.lang.Override; 026import java.lang.String; 027import java.math.BigInteger; 028import java.util.LinkedList; 029import java.util.List; 030import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 031import org.apache.commons.lang3.builder.ToStringStyle; 032 033@MetaschemaAssembly( 034 formalName = "Inline Field Definition", 035 name = "inline-define-field", 036 moduleClass = MetaschemaModelModule.class 037) 038public class InlineDefineField implements IBoundObject { 039 private final IMetaschemaData __metaschemaData; 040 041 @BoundFlag( 042 formalName = "Inline Field Name", 043 name = "name", 044 required = true, 045 typeAdapter = TokenAdapter.class 046 ) 047 private String _name; 048 049 @BoundFlag( 050 formalName = "Inline Field Binary Name", 051 name = "index", 052 typeAdapter = PositiveIntegerAdapter.class 053 ) 054 private BigInteger _index; 055 056 @BoundFlag( 057 formalName = "Deprecated Version", 058 name = "deprecated", 059 typeAdapter = StringAdapter.class 060 ) 061 private String _deprecated; 062 063 @BoundFlag( 064 formalName = "Field Value Data Type", 065 name = "as-type", 066 defaultValue = "string", 067 typeAdapter = TokenAdapter.class, 068 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "markup-line", description = "The [markup-line](https://pages.nist.gov/metaschema/specification/datatypes/#markup-line) data type."), @AllowedValue(value = "markup-multiline", description = "The [markup-multiline](https://pages.nist.gov/metaschema/specification/datatypes/#markup-multiline) data type."), @AllowedValue(value = "base64", description = "The [base64](https://pages.nist.gov/metaschema/specification/datatypes/#base64) data type."), @AllowedValue(value = "boolean", description = "The [boolean](https://pages.nist.gov/metaschema/specification/datatypes/#boolean) data type."), @AllowedValue(value = "date", description = "The [date](https://pages.nist.gov/metaschema/specification/datatypes/#date) data type."), @AllowedValue(value = "date-time", description = "The [date-time](https://pages.nist.gov/metaschema/specification/datatypes/#date-time) data type."), @AllowedValue(value = "date-time-with-timezone", description = "The [date-time-with-timezone](https://pages.nist.gov/metaschema/specification/datatypes/#date-time-with-timezone) data type."), @AllowedValue(value = "date-with-timezone", description = "The [date-with-timezone](https://pages.nist.gov/metaschema/specification/datatypes/#date-with-timezone) data type."), @AllowedValue(value = "day-time-duration", description = "The [day-time-duration](https://pages.nist.gov/metaschema/specification/datatypes/#day-time-duration) data type."), @AllowedValue(value = "decimal", description = "The [decimal](https://pages.nist.gov/metaschema/specification/datatypes/#decimal) data type."), @AllowedValue(value = "email-address", description = "The [email-address](https://pages.nist.gov/metaschema/specification/datatypes/#email-address) data type."), @AllowedValue(value = "hostname", description = "The [hostname](https://pages.nist.gov/metaschema/specification/datatypes/#hostname) data type."), @AllowedValue(value = "integer", description = "The [integer](https://pages.nist.gov/metaschema/specification/datatypes/#integer) data type."), @AllowedValue(value = "ip-v4-address", description = "The [ip-v4-address](https://pages.nist.gov/metaschema/specification/datatypes/#ip-v4-address) data type."), @AllowedValue(value = "ip-v6-address", description = "The [ip-v6-address](https://pages.nist.gov/metaschema/specification/datatypes/#ip-v6-address) data type."), @AllowedValue(value = "non-negative-integer", description = "The [non-negative-integer](https://pages.nist.gov/metaschema/specification/datatypes/#non-negative-integer) data type."), @AllowedValue(value = "positive-integer", description = "The [positive-integer](https://pages.nist.gov/metaschema/specification/datatypes/#positive-integer) data type."), @AllowedValue(value = "string", description = "The [string](https://pages.nist.gov/metaschema/specification/datatypes/#string) data type."), @AllowedValue(value = "token", description = "The [token](https://pages.nist.gov/metaschema/specification/datatypes/#token) data type."), @AllowedValue(value = "uri", description = "The [uri](https://pages.nist.gov/metaschema/specification/datatypes/#uri) data type."), @AllowedValue(value = "uri-reference", description = "The [uri-reference](https://pages.nist.gov/metaschema/specification/datatypes/#uri-reference) data type."), @AllowedValue(value = "uuid", description = "The [uuid](https://pages.nist.gov/metaschema/specification/datatypes/#uuid) data type."), @AllowedValue(value = "base64Binary", description = "An old name which is deprecated for use in favor of the 'base64' data type.", deprecatedVersion = "1.0.0"), @AllowedValue(value = "dateTime", description = "An old name which is deprecated for use in favor of the 'date-time' data type.", deprecatedVersion = "1.0.0"), @AllowedValue(value = "dateTime-with-timezone", description = "An old name which is deprecated for use in favor of the 'date-time-with-timezone' data type.", deprecatedVersion = "1.0.0"), @AllowedValue(value = "email", description = "An old name which is deprecated for use in favor of the 'email-address' data type.", deprecatedVersion = "1.0.0"), @AllowedValue(value = "nonNegativeInteger", description = "An old name which is deprecated for use in favor of the 'non-negative-integer' data type.", deprecatedVersion = "1.0.0"), @AllowedValue(value = "positiveInteger", description = "An old name which is deprecated for use in favor of the 'positive-integer' data type.", deprecatedVersion = "1.0.0")})) 069 ) 070 private String _asType; 071 072 @BoundFlag( 073 formalName = "Default Field Value", 074 name = "default", 075 typeAdapter = StringAdapter.class 076 ) 077 private String _default; 078 079 @BoundFlag( 080 formalName = "Minimum Occurrence", 081 name = "min-occurs", 082 defaultValue = "0", 083 typeAdapter = NonNegativeIntegerAdapter.class 084 ) 085 private BigInteger _minOccurs; 086 087 @BoundFlag( 088 formalName = "Maximum Occurrence", 089 name = "max-occurs", 090 defaultValue = "1", 091 typeAdapter = StringAdapter.class, 092 valueConstraints = @ValueConstraints(matches = @Matches(level = IConstraint.Level.ERROR, pattern = "^[1-9][0-9]*|unbounded$")) 093 ) 094 private String _maxOccurs; 095 096 @BoundFlag( 097 formalName = "Field In XML", 098 name = "in-xml", 099 defaultValue = "WRAPPED", 100 typeAdapter = TokenAdapter.class, 101 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "WRAPPED", description = "Block contents of a markup-multiline field will be represented with a containing (wrapper) element in the XML."), @AllowedValue(value = "UNWRAPPED", description = "Block contents of a markup-multiline will be represented in the XML with no wrapper, making the field implicit. Among sibling fields in a given model, only one of them may be designated as UNWRAPPED."), @AllowedValue(value = "WITH_WRAPPER", description = "Alias for WRAPPED.", deprecatedVersion = "0.9.0")})) 102 ) 103 private String _inXml; 104 105 @BoundField( 106 formalName = "Formal Name", 107 description = "A formal name for the data construct, to be presented in documentation.", 108 useName = "formal-name" 109 ) 110 private String _formalName; 111 112 @BoundField( 113 formalName = "Description", 114 description = "A short description of the data construct's purpose, describing the constructs semantics.", 115 useName = "description", 116 typeAdapter = MarkupLineAdapter.class 117 ) 118 private MarkupLine _description; 119 120 @BoundAssembly( 121 formalName = "Property", 122 useName = "prop", 123 maxOccurs = -1, 124 groupAs = @gov.nist.secauto.metaschema.databind.model.annotations.GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 125 ) 126 private List<Property> _props; 127 128 @BoundAssembly( 129 formalName = "JSON Key", 130 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.", 131 useName = "json-key" 132 ) 133 private JsonKey _jsonKey; 134 135 @BoundField( 136 formalName = "Field Value JSON Property Name", 137 useName = "json-value-key", 138 typeAdapter = TokenAdapter.class 139 ) 140 private String _jsonValueKey; 141 142 @BoundAssembly( 143 formalName = "Flag Used as the Field Value's JSON Property Name", 144 useName = "json-value-key-flag" 145 ) 146 private JsonValueKeyFlag _jsonValueKeyFlag; 147 148 @BoundAssembly( 149 formalName = "Group As", 150 useName = "group-as" 151 ) 152 private GroupAs _groupAs; 153 154 @BoundChoiceGroup( 155 maxOccurs = -1, 156 assemblies = { 157 @BoundGroupedAssembly(formalName = "Inline Flag Definition", useName = "define-flag", binding = InlineDefineFlag.class), 158 @BoundGroupedAssembly(formalName = "Flag Reference", useName = "flag", binding = FlagReference.class) 159 }, 160 groupAs = @gov.nist.secauto.metaschema.databind.model.annotations.GroupAs(name = "flags", inJson = JsonGroupAsBehavior.LIST) 161 ) 162 private List<Object> _flags; 163 164 @BoundAssembly( 165 useName = "constraint" 166 ) 167 private FieldConstraints _constraint; 168 169 @BoundField( 170 formalName = "Remarks", 171 description = "Any explanatory or helpful information to be provided about the remarks parent.", 172 useName = "remarks" 173 ) 174 private Remarks _remarks; 175 176 @BoundAssembly( 177 formalName = "Example", 178 useName = "example", 179 maxOccurs = -1, 180 groupAs = @gov.nist.secauto.metaschema.databind.model.annotations.GroupAs(name = "examples", inJson = JsonGroupAsBehavior.LIST) 181 ) 182 private List<Example> _examples; 183 184 public InlineDefineField() { 185 this(null); 186 } 187 188 public InlineDefineField(IMetaschemaData data) { 189 this.__metaschemaData = data; 190 } 191 192 @Override 193 public IMetaschemaData getMetaschemaData() { 194 return __metaschemaData; 195 } 196 197 public String getName() { 198 return _name; 199 } 200 201 public void setName(String value) { 202 _name = value; 203 } 204 205 public BigInteger getIndex() { 206 return _index; 207 } 208 209 public void setIndex(BigInteger value) { 210 _index = value; 211 } 212 213 public String getDeprecated() { 214 return _deprecated; 215 } 216 217 public void setDeprecated(String value) { 218 _deprecated = value; 219 } 220 221 public String getAsType() { 222 return _asType; 223 } 224 225 public void setAsType(String value) { 226 _asType = value; 227 } 228 229 public String getDefault() { 230 return _default; 231 } 232 233 public void setDefault(String value) { 234 _default = value; 235 } 236 237 public BigInteger getMinOccurs() { 238 return _minOccurs; 239 } 240 241 public void setMinOccurs(BigInteger value) { 242 _minOccurs = value; 243 } 244 245 public String getMaxOccurs() { 246 return _maxOccurs; 247 } 248 249 public void setMaxOccurs(String value) { 250 _maxOccurs = value; 251 } 252 253 public String getInXml() { 254 return _inXml; 255 } 256 257 public void setInXml(String value) { 258 _inXml = value; 259 } 260 261 public String getFormalName() { 262 return _formalName; 263 } 264 265 public void setFormalName(String value) { 266 _formalName = value; 267 } 268 269 public MarkupLine getDescription() { 270 return _description; 271 } 272 273 public void setDescription(MarkupLine value) { 274 _description = value; 275 } 276 277 public List<Property> getProps() { 278 return _props; 279 } 280 281 public void setProps(List<Property> value) { 282 _props = value; 283 } 284 285 /** 286 * Add a new {@link Property} item to the underlying collection. 287 * @param item the item to add 288 * @return {@code true} 289 */ 290 public boolean addProp(Property item) { 291 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 292 if (_props == null) { 293 _props = new LinkedList<>(); 294 } 295 return _props.add(value); 296 } 297 298 /** 299 * Remove the first matching {@link Property} item from the underlying collection. 300 * @param item the item to remove 301 * @return {@code true} if the item was removed or {@code false} otherwise 302 */ 303 public boolean removeProp(Property item) { 304 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 305 return _props != null && _props.remove(value); 306 } 307 308 public JsonKey getJsonKey() { 309 return _jsonKey; 310 } 311 312 public void setJsonKey(JsonKey value) { 313 _jsonKey = value; 314 } 315 316 public String getJsonValueKey() { 317 return _jsonValueKey; 318 } 319 320 public void setJsonValueKey(String value) { 321 _jsonValueKey = value; 322 } 323 324 public JsonValueKeyFlag getJsonValueKeyFlag() { 325 return _jsonValueKeyFlag; 326 } 327 328 public void setJsonValueKeyFlag(JsonValueKeyFlag value) { 329 _jsonValueKeyFlag = value; 330 } 331 332 public GroupAs getGroupAs() { 333 return _groupAs; 334 } 335 336 public void setGroupAs(GroupAs value) { 337 _groupAs = value; 338 } 339 340 public List<Object> getFlags() { 341 return _flags; 342 } 343 344 public void setFlags(List<Object> value) { 345 _flags = value; 346 } 347 348 public FieldConstraints getConstraint() { 349 return _constraint; 350 } 351 352 public void setConstraint(FieldConstraints value) { 353 _constraint = value; 354 } 355 356 public Remarks getRemarks() { 357 return _remarks; 358 } 359 360 public void setRemarks(Remarks value) { 361 _remarks = value; 362 } 363 364 public List<Example> getExamples() { 365 return _examples; 366 } 367 368 public void setExamples(List<Example> value) { 369 _examples = value; 370 } 371 372 /** 373 * Add a new {@link Example} item to the underlying collection. 374 * @param item the item to add 375 * @return {@code true} 376 */ 377 public boolean addExample(Example item) { 378 Example value = ObjectUtils.requireNonNull(item,"item cannot be null"); 379 if (_examples == null) { 380 _examples = new LinkedList<>(); 381 } 382 return _examples.add(value); 383 } 384 385 /** 386 * Remove the first matching {@link Example} item from the underlying collection. 387 * @param item the item to remove 388 * @return {@code true} if the item was removed or {@code false} otherwise 389 */ 390 public boolean removeExample(Example item) { 391 Example value = ObjectUtils.requireNonNull(item,"item cannot be null"); 392 return _examples != null && _examples.remove(value); 393 } 394 395 @Override 396 public String toString() { 397 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 398 } 399}