1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.databind.testing.model;
7   
8   import gov.nist.secauto.metaschema.core.model.IBoundObject;
9   import gov.nist.secauto.metaschema.core.model.IMetaschemaData;
10  import gov.nist.secauto.metaschema.core.model.JsonGroupAsBehavior;
11  import gov.nist.secauto.metaschema.core.model.XmlGroupAsBehavior;
12  import gov.nist.secauto.metaschema.databind.model.annotations.BoundField;
13  import gov.nist.secauto.metaschema.databind.model.annotations.BoundFieldValue;
14  import gov.nist.secauto.metaschema.databind.model.annotations.BoundFlag;
15  import gov.nist.secauto.metaschema.databind.model.annotations.GroupAs;
16  import gov.nist.secauto.metaschema.databind.model.annotations.JsonFieldValueKeyFlag;
17  import gov.nist.secauto.metaschema.databind.model.annotations.JsonKey;
18  import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaAssembly;
19  import gov.nist.secauto.metaschema.databind.model.annotations.MetaschemaField;
20  
21  import java.util.List;
22  import java.util.Map;
23  
24  import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
25  
26  // Used
27  @SuppressWarnings({ "PMD", "checkstyle:MemberNameCheck" })
28  @MetaschemaAssembly(
29      name = "assembly-with-fields",
30      rootName = "root-assembly-with-fields",
31      moduleClass = TestModule.class)
32  public class RootAssemblyWithFields implements IBoundObject {
33    private final IMetaschemaData metaschemaData;
34  
35    @BoundField
36    private String defaultField;
37  
38    @BoundField(useName = "field2",
39        maxOccurs = -1,
40        groupAs = @GroupAs(name = "fields2",
41            inXml = XmlGroupAsBehavior.GROUPED,
42            inJson = JsonGroupAsBehavior.LIST))
43    private List<String> _field2;
44  
45    @BoundField
46    private ValueKeyField field3;
47  
48    @BoundField
49    private DefaultValueKeyField field4;
50  
51    @BoundField
52    private FlagValueKeyField field5;
53  
54    @BoundField(
55        maxOccurs = -1,
56        groupAs = @GroupAs(name = "fields6",
57            inXml = XmlGroupAsBehavior.UNGROUPED,
58            inJson = JsonGroupAsBehavior.KEYED))
59    private Map<String, JsonKeyField> field6;
60  
61    public RootAssemblyWithFields() {
62      this(null);
63    }
64  
65    public RootAssemblyWithFields(IMetaschemaData metaschemaData) {
66      this.metaschemaData = metaschemaData;
67    }
68  
69    @Override
70    public IMetaschemaData getMetaschemaData() {
71      return metaschemaData;
72    }
73  
74    public String getField1() {
75      return defaultField;
76    }
77  
78    @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "this is a data holder")
79    public List<String> getField2() {
80      return _field2;
81    }
82  
83    public ValueKeyField getField3() {
84      return field3;
85    }
86  
87    public void setField3(ValueKeyField field3) {
88      this.field3 = field3;
89    }
90  
91    public DefaultValueKeyField getField4() {
92      return field4;
93    }
94  
95    public void setField4(DefaultValueKeyField field4) {
96      this.field4 = field4;
97    }
98  
99    public FlagValueKeyField getField5() {
100     return field5;
101   }
102 
103   public void setField5(FlagValueKeyField field5) {
104     this.field5 = field5;
105   }
106 
107   public Map<String, JsonKeyField> getField6() {
108     return field6;
109   }
110 
111   public void setField6(Map<String, JsonKeyField> field6) {
112     this.field6 = field6;
113   }
114 
115   @SuppressWarnings("PMD")
116   @MetaschemaField(
117       name = "field-value-key",
118       moduleClass = TestModule.class)
119   public static class ValueKeyField implements IBoundObject {
120     private final IMetaschemaData metaschemaData;
121 
122     @BoundFlag
123     private String flag;
124 
125     @BoundFieldValue(valueKeyName = "a-value")
126     private String _value;
127 
128     public ValueKeyField() {
129       this(null);
130     }
131 
132     public ValueKeyField(IMetaschemaData metaschemaData) {
133       this.metaschemaData = metaschemaData;
134     }
135 
136     @Override
137     public IMetaschemaData getMetaschemaData() {
138       return metaschemaData;
139     }
140 
141     public String getFlag() {
142       return flag;
143     }
144 
145     public String getValue() {
146       return _value;
147     }
148   }
149 
150   @SuppressWarnings("PMD")
151   @MetaschemaField(
152       name = "field-default-value-key",
153       moduleClass = TestModule.class)
154   public static class DefaultValueKeyField implements IBoundObject {
155     private final IMetaschemaData metaschemaData;
156 
157     @BoundFlag
158     private String flag;
159 
160     @BoundFieldValue
161     private String _value;
162 
163     public DefaultValueKeyField() {
164       this(null);
165     }
166 
167     public DefaultValueKeyField(IMetaschemaData metaschemaData) {
168       this.metaschemaData = metaschemaData;
169     }
170 
171     @Override
172     public IMetaschemaData getMetaschemaData() {
173       return metaschemaData;
174     }
175 
176     public String getFlag() {
177       return flag;
178     }
179 
180     public String getValue() {
181       return _value;
182     }
183   }
184 
185   @SuppressWarnings("PMD")
186   @MetaschemaField(
187       name = "field-flag-value-key",
188       moduleClass = TestModule.class)
189   public static class FlagValueKeyField implements IBoundObject {
190     private final IMetaschemaData metaschemaData;
191 
192     @BoundFlag
193     @JsonFieldValueKeyFlag
194     private String flag;
195 
196     @BoundFieldValue
197     private String _value;
198 
199     public FlagValueKeyField() {
200       this(null);
201     }
202 
203     public FlagValueKeyField(IMetaschemaData metaschemaData) {
204       this.metaschemaData = metaschemaData;
205     }
206 
207     @Override
208     public IMetaschemaData getMetaschemaData() {
209       return metaschemaData;
210     }
211 
212     public String getFlag() {
213       return flag;
214     }
215 
216     public String getValue() {
217       return _value;
218     }
219   }
220 
221   @SuppressWarnings("PMD")
222   @MetaschemaField(
223       name = "field-json-key",
224       moduleClass = TestModule.class)
225   public static class JsonKeyField implements IBoundObject {
226     private final IMetaschemaData metaschemaData;
227 
228     @BoundFlag
229     @JsonKey
230     private String key;
231 
232     @BoundFlag
233     @JsonFieldValueKeyFlag
234     private String valueKey;
235 
236     @BoundFieldValue
237     private String _value;
238 
239     public JsonKeyField() {
240       this(null);
241     }
242 
243     public JsonKeyField(IMetaschemaData metaschemaData) {
244       this.metaschemaData = metaschemaData;
245     }
246 
247     @Override
248     public IMetaschemaData getMetaschemaData() {
249       return metaschemaData;
250     }
251 
252     public String getKey() {
253       return key;
254     }
255 
256     public String getValueKey() {
257       return valueKey;
258     }
259 
260     public String getValue() {
261       return _value;
262     }
263   }
264 }