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