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.BoundField;
018import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
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.Override;
023import java.lang.String;
024import java.math.BigInteger;
025import java.util.LinkedList;
026import java.util.List;
027import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
028import org.apache.commons.lang3.builder.ToStringStyle;
029
030@MetaschemaAssembly(
031    formalName = "Field Reference",
032    name = "field-reference",
033    moduleClass = MetaschemaModelModule.class
034)
035public class FieldReference implements IBoundObject {
036  private final IMetaschemaData __metaschemaData;
037
038  @BoundFlag(
039      formalName = "Global Field Reference",
040      name = "ref",
041      required = true,
042      typeAdapter = TokenAdapter.class
043  )
044  private String _ref;
045
046  @BoundFlag(
047      formalName = "Field Reference Binary Name",
048      name = "index",
049      typeAdapter = PositiveIntegerAdapter.class
050  )
051  private BigInteger _index;
052
053  @BoundFlag(
054      formalName = "Deprecated Version",
055      name = "deprecated",
056      typeAdapter = StringAdapter.class
057  )
058  private String _deprecated;
059
060  @BoundFlag(
061      formalName = "Default Field Value",
062      name = "default",
063      typeAdapter = StringAdapter.class
064  )
065  private String _default;
066
067  @BoundFlag(
068      formalName = "Minimum Occurrence",
069      name = "min-occurs",
070      defaultValue = "0",
071      typeAdapter = NonNegativeIntegerAdapter.class
072  )
073  private BigInteger _minOccurs;
074
075  @BoundFlag(
076      formalName = "Maximum Occurrence",
077      name = "max-occurs",
078      defaultValue = "1",
079      typeAdapter = StringAdapter.class,
080      valueConstraints = @ValueConstraints(matches = @Matches(level = IConstraint.Level.ERROR, pattern = "^[1-9][0-9]*|unbounded$"))
081  )
082  private String _maxOccurs;
083
084  @BoundFlag(
085      formalName = "Field In XML",
086      name = "in-xml",
087      defaultValue = "WRAPPED",
088      typeAdapter = TokenAdapter.class,
089      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")}))
090  )
091  private String _inXml;
092
093  @BoundField(
094      formalName = "Formal Name",
095      description = "A formal name for the data construct, to be presented in documentation.",
096      useName = "formal-name"
097  )
098  private String _formalName;
099
100  @BoundField(
101      formalName = "Description",
102      description = "A short description of the data construct's purpose, describing the constructs semantics.",
103      useName = "description",
104      typeAdapter = MarkupLineAdapter.class
105  )
106  private MarkupLine _description;
107
108  @BoundAssembly(
109      formalName = "Property",
110      useName = "prop",
111      maxOccurs = -1,
112      groupAs = @gov.nist.secauto.metaschema.databind.model.annotations.GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
113  )
114  private List<Property> _props;
115
116  @BoundField(
117      formalName = "Use Name",
118      description = "Allows the name of the definition to be overridden.",
119      useName = "use-name"
120  )
121  private UseName _useName;
122
123  @BoundAssembly(
124      formalName = "Group As",
125      useName = "group-as"
126  )
127  private GroupAs _groupAs;
128
129  @BoundField(
130      formalName = "Remarks",
131      description = "Any explanatory or helpful information to be provided about the remarks parent.",
132      useName = "remarks"
133  )
134  private Remarks _remarks;
135
136  public FieldReference() {
137    this(null);
138  }
139
140  public FieldReference(IMetaschemaData data) {
141    this.__metaschemaData = data;
142  }
143
144  @Override
145  public IMetaschemaData getMetaschemaData() {
146    return __metaschemaData;
147  }
148
149  public String getRef() {
150    return _ref;
151  }
152
153  public void setRef(String value) {
154    _ref = value;
155  }
156
157  public BigInteger getIndex() {
158    return _index;
159  }
160
161  public void setIndex(BigInteger value) {
162    _index = value;
163  }
164
165  public String getDeprecated() {
166    return _deprecated;
167  }
168
169  public void setDeprecated(String value) {
170    _deprecated = value;
171  }
172
173  public String getDefault() {
174    return _default;
175  }
176
177  public void setDefault(String value) {
178    _default = value;
179  }
180
181  public BigInteger getMinOccurs() {
182    return _minOccurs;
183  }
184
185  public void setMinOccurs(BigInteger value) {
186    _minOccurs = value;
187  }
188
189  public String getMaxOccurs() {
190    return _maxOccurs;
191  }
192
193  public void setMaxOccurs(String value) {
194    _maxOccurs = value;
195  }
196
197  public String getInXml() {
198    return _inXml;
199  }
200
201  public void setInXml(String value) {
202    _inXml = value;
203  }
204
205  public String getFormalName() {
206    return _formalName;
207  }
208
209  public void setFormalName(String value) {
210    _formalName = value;
211  }
212
213  public MarkupLine getDescription() {
214    return _description;
215  }
216
217  public void setDescription(MarkupLine value) {
218    _description = value;
219  }
220
221  public List<Property> getProps() {
222    return _props;
223  }
224
225  public void setProps(List<Property> value) {
226    _props = value;
227  }
228
229  /**
230   * Add a new {@link Property} item to the underlying collection.
231   * @param item the item to add
232   * @return {@code true}
233   */
234  public boolean addProp(Property item) {
235    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
236    if (_props == null) {
237      _props = new LinkedList<>();
238    }
239    return _props.add(value);
240  }
241
242  /**
243   * Remove the first matching {@link Property} item from the underlying collection.
244   * @param item the item to remove
245   * @return {@code true} if the item was removed or {@code false} otherwise
246   */
247  public boolean removeProp(Property item) {
248    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
249    return _props != null && _props.remove(value);
250  }
251
252  public UseName getUseName() {
253    return _useName;
254  }
255
256  public void setUseName(UseName value) {
257    _useName = value;
258  }
259
260  public GroupAs getGroupAs() {
261    return _groupAs;
262  }
263
264  public void setGroupAs(GroupAs value) {
265    _groupAs = value;
266  }
267
268  public Remarks getRemarks() {
269    return _remarks;
270  }
271
272  public void setRemarks(Remarks value) {
273    _remarks = value;
274  }
275
276  @Override
277  public String toString() {
278    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
279  }
280}