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 = "Value Matches Constraint",
029    name = "targeted-matches-constraint",
030    moduleClass = MetaschemaModelModule.class
031)
032public class TargetedMatchesConstraint 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 = "Matches Regular Expression",
053      name = "regex",
054      typeAdapter = StringAdapter.class
055  )
056  private String _regex;
057
058  @BoundFlag(
059      formalName = "Matches Data Type",
060      name = "datatype",
061      typeAdapter = TokenAdapter.class,
062      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, allowOthers = true, values = {@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")}))
063  )
064  private String _datatype;
065
066  @BoundFlag(
067      formalName = "Constraint Target Metapath Expression",
068      name = "target",
069      required = true,
070      typeAdapter = StringAdapter.class
071  )
072  private String _target;
073
074  @BoundField(
075      formalName = "Formal Name",
076      description = "A formal name for the data construct, to be presented in documentation.",
077      useName = "formal-name"
078  )
079  private String _formalName;
080
081  @BoundField(
082      formalName = "Description",
083      description = "A short description of the data construct's purpose, describing the constructs semantics.",
084      useName = "description",
085      typeAdapter = MarkupLineAdapter.class
086  )
087  private MarkupLine _description;
088
089  @BoundAssembly(
090      formalName = "Property",
091      useName = "prop",
092      maxOccurs = -1,
093      groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST)
094  )
095  private List<Property> _props;
096
097  @BoundField(
098      formalName = "Constraint Condition Violation Message",
099      useName = "message"
100  )
101  private String _message;
102
103  @BoundField(
104      formalName = "Remarks",
105      description = "Any explanatory or helpful information to be provided about the remarks parent.",
106      useName = "remarks"
107  )
108  private Remarks _remarks;
109
110  public TargetedMatchesConstraint() {
111    this(null);
112  }
113
114  public TargetedMatchesConstraint(IMetaschemaData data) {
115    this.__metaschemaData = data;
116  }
117
118  @Override
119  public IMetaschemaData getMetaschemaData() {
120    return __metaschemaData;
121  }
122
123  public String getId() {
124    return _id;
125  }
126
127  public void setId(String value) {
128    _id = value;
129  }
130
131  public String getLevel() {
132    return _level;
133  }
134
135  public void setLevel(String value) {
136    _level = value;
137  }
138
139  public String getRegex() {
140    return _regex;
141  }
142
143  public void setRegex(String value) {
144    _regex = value;
145  }
146
147  public String getDatatype() {
148    return _datatype;
149  }
150
151  public void setDatatype(String value) {
152    _datatype = value;
153  }
154
155  public String getTarget() {
156    return _target;
157  }
158
159  public void setTarget(String value) {
160    _target = value;
161  }
162
163  public String getFormalName() {
164    return _formalName;
165  }
166
167  public void setFormalName(String value) {
168    _formalName = value;
169  }
170
171  public MarkupLine getDescription() {
172    return _description;
173  }
174
175  public void setDescription(MarkupLine value) {
176    _description = value;
177  }
178
179  public List<Property> getProps() {
180    return _props;
181  }
182
183  public void setProps(List<Property> value) {
184    _props = value;
185  }
186
187  /**
188   * Add a new {@link Property} item to the underlying collection.
189   * @param item the item to add
190   * @return {@code true}
191   */
192  public boolean addProp(Property item) {
193    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
194    if (_props == null) {
195      _props = new LinkedList<>();
196    }
197    return _props.add(value);
198  }
199
200  /**
201   * Remove the first matching {@link Property} item from the underlying collection.
202   * @param item the item to remove
203   * @return {@code true} if the item was removed or {@code false} otherwise
204   */
205  public boolean removeProp(Property item) {
206    Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
207    return _props != null && _props.remove(value);
208  }
209
210  public String getMessage() {
211    return _message;
212  }
213
214  public void setMessage(String value) {
215    _message = value;
216  }
217
218  public Remarks getRemarks() {
219    return _remarks;
220  }
221
222  public void setRemarks(Remarks value) {
223    _remarks = value;
224  }
225
226  @Override
227  public String toString() {
228    return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString();
229  }
230}