001package com.example.metaschema;
002
003import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter;
004import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter;
005import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine;
006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter;
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.AllowedValue;
013import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues;
014import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly;
015import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
016import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
017import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
018import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
019import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints;
020import java.lang.Override;
021import java.lang.String;
022import java.util.LinkedList;
023import java.util.List;
024import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
025import org.apache.commons.lang3.builder.ToStringStyle;
026
027@MetaschemaAssembly(
028    formalName = "Targeted Index Constraint",
029    name = "targeted-index-constraint",
030    moduleClass = MetaschemaModelModule.class
031)
032public class TargetedIndexConstraint implements IBoundObject {
033  private final IMetaschemaData __metaschemaData;
034
035  @BoundFlag(
036      formalName = "Constraint Identifier",
037      name = "id",
038      typeAdapter = TokenAdapter.class
039  )
040  private String _id;
041
042  @BoundFlag(
043      formalName = "Constraint Severity Level",
044      name = "level",
045      defaultValue = "ERROR",
046      typeAdapter = TokenAdapter.class,
047      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "CRITICAL", description = "A violation of the constraint represents a serious fault in the content that will prevent typical use of the content."), @AllowedValue(value = "ERROR", description = "A violation of the constraint represents a fault in the content. This may include issues around compatibility, integrity, consistency, etc."), @AllowedValue(value = "WARNING", description = "A violation of the constraint represents a potential issue with the content."), @AllowedValue(value = "INFORMATIONAL", description = "A violation of the constraint represents a point of interest."), @AllowedValue(value = "DEBUG", description = "A violation of the constraint represents a fault in the content that may warrant review by a developer when performing model or tool development.")}))
048  )
049  private String _level;
050
051  @BoundFlag(
052      formalName = "Index Name",
053      name = "name",
054      required = true,
055      typeAdapter = TokenAdapter.class
056  )
057  private String _name;
058
059  @BoundFlag(
060      formalName = "Constraint Target Metapath Expression",
061      name = "target",
062      required = true,
063      typeAdapter = StringAdapter.class
064  )
065  private String _target;
066
067  @BoundField(
068      formalName = "Formal Name",
069      description = "A formal name for the data construct, to be presented in documentation.",
070      useName = "formal-name"
071  )
072  private String _formalName;
073
074  @BoundField(
075      formalName = "Description",
076      description = "A short description of the data construct's purpose, describing the constructs semantics.",
077      useName = "description",
078      typeAdapter = MarkupLineAdapter.class
079  )
080  private MarkupLine _description;
081
082  @BoundAssembly(
083      formalName = "Property",
084      useName = "prop",
085      maxOccurs = -1,
086      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
087  )
088  private List<Property> _props;
089
090  @BoundAssembly(
091      formalName = "Key Constraint Field",
092      useName = "key-field",
093      minOccurs = 1,
094      maxOccurs = -1,
095      groupAs = @GroupAs(name = "key-fields", inJson = JsonGroupAsBehavior.LIST)
096  )
097  private List<KeyConstraintField> _keyFields;
098
099  @BoundField(
100      formalName = "Constraint Condition Violation Message",
101      useName = "message"
102  )
103  private String _message;
104
105  @BoundField(
106      formalName = "Remarks",
107      description = "Any explanatory or helpful information to be provided about the remarks parent.",
108      useName = "remarks"
109  )
110  private Remarks _remarks;
111
112  public TargetedIndexConstraint() {
113    this(null);
114  }
115
116  public TargetedIndexConstraint(IMetaschemaData data) {
117    this.__metaschemaData = data;
118  }
119
120  @Override
121  public IMetaschemaData getMetaschemaData() {
122    return __metaschemaData;
123  }
124
125  public String getId() {
126    return _id;
127  }
128
129  public void setId(String value) {
130    _id = value;
131  }
132
133  public String getLevel() {
134    return _level;
135  }
136
137  public void setLevel(String value) {
138    _level = value;
139  }
140
141  public String getName() {
142    return _name;
143  }
144
145  public void setName(String value) {
146    _name = value;
147  }
148
149  public String getTarget() {
150    return _target;
151  }
152
153  public void setTarget(String value) {
154    _target = value;
155  }
156
157  public String getFormalName() {
158    return _formalName;
159  }
160
161  public void setFormalName(String value) {
162    _formalName = value;
163  }
164
165  public MarkupLine getDescription() {
166    return _description;
167  }
168
169  public void setDescription(MarkupLine value) {
170    _description = value;
171  }
172
173  public List<Property> getProps() {
174    return _props;
175  }
176
177  public void setProps(List<Property> value) {
178    _props = value;
179  }
180
181  /**
182   * Add a new {@link Property} item to the underlying collection.
183   * @param item the item to add
184   * @return {@code true}
185   */
186  public boolean addProp(Property item) {
187    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
188    if (_props == null) {
189      _props = new LinkedList<>();
190    }
191    return _props.add(value);
192  }
193
194  /**
195   * Remove the first matching {@link Property} item from the underlying collection.
196   * @param item the item to remove
197   * @return {@code true} if the item was removed or {@code false} otherwise
198   */
199  public boolean removeProp(Property item) {
200    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
201    return _props != null && _props.remove(value);
202  }
203
204  public List<KeyConstraintField> getKeyFields() {
205    return _keyFields;
206  }
207
208  public void setKeyFields(List<KeyConstraintField> value) {
209    _keyFields = value;
210  }
211
212  /**
213   * Add a new {@link KeyConstraintField} item to the underlying collection.
214   * @param item the item to add
215   * @return {@code true}
216   */
217  public boolean addKeyField(KeyConstraintField item) {
218    KeyConstraintField value = ObjectUtils.requireNonNull(item,"item cannot be null");
219    if (_keyFields == null) {
220      _keyFields = new LinkedList<>();
221    }
222    return _keyFields.add(value);
223  }
224
225  /**
226   * Remove the first matching {@link KeyConstraintField} item from the underlying collection.
227   * @param item the item to remove
228   * @return {@code true} if the item was removed or {@code false} otherwise
229   */
230  public boolean removeKeyField(KeyConstraintField item) {
231    KeyConstraintField value = ObjectUtils.requireNonNull(item,"item cannot be null");
232    return _keyFields != null && _keyFields.remove(value);
233  }
234
235  public String getMessage() {
236    return _message;
237  }
238
239  public void setMessage(String value) {
240    _message = value;
241  }
242
243  public Remarks getRemarks() {
244    return _remarks;
245  }
246
247  public void setRemarks(Remarks value) {
248    _remarks = value;
249  }
250
251  @Override
252  public String toString() {
253    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
254  }
255}