1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package dev.metaschema.databind.model.info;
7
8 import java.io.IOException;
9
10 import dev.metaschema.core.model.IBoundObject;
11 import dev.metaschema.databind.model.IBoundDefinitionModelAssembly;
12 import dev.metaschema.databind.model.IBoundDefinitionModelFieldComplex;
13 import dev.metaschema.databind.model.IBoundFieldValue;
14 import dev.metaschema.databind.model.IBoundInstanceFlag;
15 import dev.metaschema.databind.model.IBoundInstanceModelAssembly;
16 import dev.metaschema.databind.model.IBoundInstanceModelChoiceGroup;
17 import dev.metaschema.databind.model.IBoundInstanceModelFieldComplex;
18 import dev.metaschema.databind.model.IBoundInstanceModelFieldScalar;
19 import dev.metaschema.databind.model.IBoundInstanceModelGroupedAssembly;
20 import dev.metaschema.databind.model.IBoundInstanceModelGroupedField;
21 import edu.umd.cs.findbugs.annotations.NonNull;
22
23 /**
24 * Handler interface for writing bound items during serialization.
25 * <p>
26 * Implementations of this interface handle the writing of different types of
27 * model items (flags, fields, assemblies, choice groups).
28 */
29 public interface IItemWriteHandler {
30 /**
31 * Write an item.
32 *
33 * @param item
34 * the Java object representing the item to write
35 * @param instance
36 * the flag instance
37 * @throws IOException
38 * if an error occurred while parsing
39 */
40 void writeItemFlag(
41 @NonNull Object item,
42 @NonNull IBoundInstanceFlag instance) throws IOException;
43
44 /**
45 * Write an item.
46 *
47 * @param item
48 * the Java object representing the item to write
49 * @param instance
50 * the field instance
51 * @throws IOException
52 * if an error occurred while parsing
53 */
54 void writeItemField(
55 @NonNull Object item,
56 @NonNull IBoundInstanceModelFieldScalar instance) throws IOException;
57
58 /**
59 * Write an item.
60 *
61 * @param item
62 * the Java object representing the item to write
63 * @param instance
64 * the field instance
65 * @throws IOException
66 * if an error occurred while parsing
67 */
68 void writeItemField(
69 @NonNull IBoundObject item,
70 @NonNull IBoundInstanceModelFieldComplex instance) throws IOException;
71
72 /**
73 * Write an item.
74 *
75 * @param item
76 * the Java object representing the item to write
77 * @param instance
78 * the field instance
79 * @throws IOException
80 * if an error occurred while parsing
81 */
82 void writeItemField(
83 @NonNull IBoundObject item,
84 @NonNull IBoundInstanceModelGroupedField instance) throws IOException;
85
86 /**
87 * Write an item.
88 *
89 * @param item
90 * the Java object representing the item to write
91 * @param definition
92 * the field instance
93 * @throws IOException
94 * if an error occurred while parsing
95 */
96 void writeItemField(
97 @NonNull IBoundObject item,
98 @NonNull IBoundDefinitionModelFieldComplex definition) throws IOException;
99
100 /**
101 * Write an item.
102 *
103 * @param item
104 * the Java object representing the item to write
105 * @param fieldValue
106 * the field value instance
107 * @throws IOException
108 * if an error occurred while parsing
109 */
110 void writeItemFieldValue(
111 @NonNull Object item,
112 @NonNull IBoundFieldValue fieldValue) throws IOException;
113
114 /**
115 * Write an item.
116 *
117 * @param item
118 * the Java object representing the item to write
119 * @param instance
120 * the assembly instance
121 * @throws IOException
122 * if an error occurred while parsing
123 */
124 void writeItemAssembly(
125 @NonNull IBoundObject item,
126 @NonNull IBoundInstanceModelAssembly instance) throws IOException;
127
128 /**
129 * Write an item.
130 *
131 * @param item
132 * the Java object representing the item to write
133 * @param instance
134 * the assembly instance
135 * @throws IOException
136 * if an error occurred while parsing
137 */
138 void writeItemAssembly(
139 @NonNull IBoundObject item,
140 @NonNull IBoundInstanceModelGroupedAssembly instance) throws IOException;
141
142 /**
143 * Write an item.
144 *
145 * @param item
146 * the Java object representing the item to write
147 * @param definition
148 * the assembly instance
149 * @throws IOException
150 * if an error occurred while parsing
151 */
152 void writeItemAssembly(
153 @NonNull IBoundObject item,
154 @NonNull IBoundDefinitionModelAssembly definition) throws IOException;
155
156 /**
157 * Write an item.
158 *
159 * @param item
160 * the Java object representing the item to write
161 * @param instance
162 * the choice group instance
163 * @throws IOException
164 * if an error occurred while parsing
165 */
166 void writeChoiceGroupItem(
167 @NonNull IBoundObject item,
168 @NonNull IBoundInstanceModelChoiceGroup instance) throws IOException;
169
170 }