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