001package com.example.metaschema; 002 003import gov.nist.secauto.metaschema.core.datatype.adapter.PositiveIntegerAdapter; 004import gov.nist.secauto.metaschema.core.datatype.adapter.StringAdapter; 005import gov.nist.secauto.metaschema.core.datatype.adapter.TokenAdapter; 006import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; 007import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLineAdapter; 008import gov.nist.secauto.metaschema.core.model.IBoundObject; 009import gov.nist.secauto.metaschema.core.model.IMetaschemaData; 010import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior; 011import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; 012import gov.nist.secauto.metaschema.core.util.ObjectUtils; 013import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValue; 014import gov.nist.secauto.metaschema.databind.model.annotations.AllowedValues; 015import gov.nist.secauto.metaschema.databind.model.annotations.BoundAssembly; 016import gov.nist.secauto.metaschema.databind.model.annotations.BoundField; 017import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag; 018import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs; 019import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly; 020import gov.nist.secauto.metaschema.databind.model.annotations.ValueConstraints; 021import java.lang.Override; 022import java.lang.String; 023import java.math.BigInteger; 024import java.util.LinkedList; 025import java.util.List; 026import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 027import org.apache.commons.lang3.builder.ToStringStyle; 028 029@MetaschemaAssembly( 030 formalName = "Flag Reference", 031 name = "flag-reference", 032 moduleClass = MetaschemaModelModule.class 033) 034public class FlagReference implements IBoundObject { 035 private final IMetaschemaData __metaschemaData; 036 037 @BoundFlag( 038 formalName = "Global Flag Reference", 039 name = "ref", 040 required = true, 041 typeAdapter = TokenAdapter.class 042 ) 043 private String _ref; 044 045 @BoundFlag( 046 formalName = "Flag Reference Binary Name", 047 name = "index", 048 typeAdapter = PositiveIntegerAdapter.class 049 ) 050 private BigInteger _index; 051 052 @BoundFlag( 053 formalName = "Deprecated Version", 054 name = "deprecated", 055 typeAdapter = StringAdapter.class 056 ) 057 private String _deprecated; 058 059 @BoundFlag( 060 formalName = "Default Flag Value", 061 name = "default", 062 typeAdapter = StringAdapter.class 063 ) 064 private String _default; 065 066 @BoundFlag( 067 formalName = "Is Flag Required?", 068 name = "required", 069 defaultValue = "no", 070 typeAdapter = TokenAdapter.class, 071 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "yes", description = "The flag is required."), @AllowedValue(value = "no", description = "The flag is optional.")})) 072 ) 073 private String _required; 074 075 @BoundField( 076 formalName = "Formal Name", 077 description = "A formal name for the data construct, to be presented in documentation.", 078 useName = "formal-name" 079 ) 080 private String _formalName; 081 082 @BoundField( 083 formalName = "Description", 084 description = "A short description of the data construct's purpose, describing the constructs semantics.", 085 useName = "description", 086 typeAdapter = MarkupLineAdapter.class 087 ) 088 private MarkupLine _description; 089 090 @BoundAssembly( 091 formalName = "Property", 092 useName = "prop", 093 maxOccurs = -1, 094 groupAs = @GroupAs(name = "props", inJson = JsonGroupAsBehavior.LIST) 095 ) 096 private List<Property> _props; 097 098 @BoundField( 099 formalName = "Use Name", 100 description = "Allows the name of the definition to be overridden.", 101 useName = "use-name" 102 ) 103 private UseName _useName; 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 FlagReference() { 113 this(null); 114 } 115 116 public FlagReference(IMetaschemaData data) { 117 this.__metaschemaData = data; 118 } 119 120 @Override 121 public IMetaschemaData getMetaschemaData() { 122 return __metaschemaData; 123 } 124 125 public String getRef() { 126 return _ref; 127 } 128 129 public void setRef(String value) { 130 _ref = value; 131 } 132 133 public BigInteger getIndex() { 134 return _index; 135 } 136 137 public void setIndex(BigInteger value) { 138 _index = value; 139 } 140 141 public String getDeprecated() { 142 return _deprecated; 143 } 144 145 public void setDeprecated(String value) { 146 _deprecated = value; 147 } 148 149 public String getDefault() { 150 return _default; 151 } 152 153 public void setDefault(String value) { 154 _default = value; 155 } 156 157 public String getRequired() { 158 return _required; 159 } 160 161 public void setRequired(String value) { 162 _required = value; 163 } 164 165 public String getFormalName() { 166 return _formalName; 167 } 168 169 public void setFormalName(String value) { 170 _formalName = value; 171 } 172 173 public MarkupLine getDescription() { 174 return _description; 175 } 176 177 public void setDescription(MarkupLine value) { 178 _description = value; 179 } 180 181 public List<Property> getProps() { 182 return _props; 183 } 184 185 public void setProps(List<Property> value) { 186 _props = value; 187 } 188 189 /** 190 * Add a new {@link Property} item to the underlying collection. 191 * @param item the item to add 192 * @return {@code true} 193 */ 194 public boolean addProp(Property item) { 195 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 196 if (_props == null) { 197 _props = new LinkedList<>(); 198 } 199 return _props.add(value); 200 } 201 202 /** 203 * Remove the first matching {@link Property} item from the underlying collection. 204 * @param item the item to remove 205 * @return {@code true} if the item was removed or {@code false} otherwise 206 */ 207 public boolean removeProp(Property item) { 208 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 209 return _props != null && _props.remove(value); 210 } 211 212 public UseName getUseName() { 213 return _useName; 214 } 215 216 public void setUseName(UseName value) { 217 _useName = value; 218 } 219 220 public Remarks getRemarks() { 221 return _remarks; 222 } 223 224 public void setRemarks(Remarks value) { 225 _remarks = value; 226 } 227 228 @Override 229 public String toString() { 230 return new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString(); 231 } 232}