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