1
2
3
4
5
6 package gov.nist.secauto.metaschema.schemagen.json.impl.builder;
7
8 import com.fasterxml.jackson.databind.node.ObjectNode;
9
10 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
11 import gov.nist.secauto.metaschema.schemagen.json.IJsonGenerationState;
12
13 public class ArrayBuilder
14 extends AbstractCollectionBuilder<ArrayBuilder> {
15
16 @Override
17 public void build(
18 ObjectNode object,
19 IJsonGenerationState state) {
20 object.put("type", "array");
21
22 if (!getTypes().isEmpty()) {
23 ObjectNode items = ObjectUtils.notNull(object.putObject("items"));
24 buildInternal(items, state);
25 }
26
27 if (getMinOccurrence() > 1) {
28 object.put("minItems", getMinOccurrence());
29 } else {
30 object.put("minItems", 1);
31 }
32
33 if (getMaxOccurrence() != -1) {
34 object.put("maxItems", getMaxOccurrence());
35 }
36 }
37
38 @Override
39 protected ArrayBuilder thisBuilder() {
40 return this;
41 }
42 }