001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.databind.model.info; 007 008import java.io.IOException; 009 010import dev.metaschema.core.model.IBoundObject; 011import dev.metaschema.databind.model.IBoundDefinitionModelAssembly; 012import dev.metaschema.databind.model.IBoundDefinitionModelFieldComplex; 013import dev.metaschema.databind.model.IBoundFieldValue; 014import dev.metaschema.databind.model.IBoundInstanceFlag; 015import dev.metaschema.databind.model.IBoundInstanceModelAssembly; 016import dev.metaschema.databind.model.IBoundInstanceModelChoiceGroup; 017import dev.metaschema.databind.model.IBoundInstanceModelFieldComplex; 018import dev.metaschema.databind.model.IBoundInstanceModelFieldScalar; 019import dev.metaschema.databind.model.IBoundInstanceModelGroupedAssembly; 020import dev.metaschema.databind.model.IBoundInstanceModelGroupedField; 021import edu.umd.cs.findbugs.annotations.NonNull; 022 023/** 024 * Handler interface for writing bound items during serialization. 025 * <p> 026 * Implementations of this interface handle the writing of different types of 027 * model items (flags, fields, assemblies, choice groups). 028 */ 029public interface IItemWriteHandler { 030 /** 031 * Write an item. 032 * 033 * @param item 034 * the Java object representing the item to write 035 * @param instance 036 * the flag instance 037 * @throws IOException 038 * if an error occurred while parsing 039 */ 040 void writeItemFlag( 041 @NonNull Object item, 042 @NonNull IBoundInstanceFlag instance) throws IOException; 043 044 /** 045 * Write an item. 046 * 047 * @param item 048 * the Java object representing the item to write 049 * @param instance 050 * the field instance 051 * @throws IOException 052 * if an error occurred while parsing 053 */ 054 void writeItemField( 055 @NonNull Object item, 056 @NonNull IBoundInstanceModelFieldScalar instance) throws IOException; 057 058 /** 059 * Write an item. 060 * 061 * @param item 062 * the Java object representing the item to write 063 * @param instance 064 * the field instance 065 * @throws IOException 066 * if an error occurred while parsing 067 */ 068 void writeItemField( 069 @NonNull IBoundObject item, 070 @NonNull IBoundInstanceModelFieldComplex instance) throws IOException; 071 072 /** 073 * Write an item. 074 * 075 * @param item 076 * the Java object representing the item to write 077 * @param instance 078 * the field instance 079 * @throws IOException 080 * if an error occurred while parsing 081 */ 082 void writeItemField( 083 @NonNull IBoundObject item, 084 @NonNull IBoundInstanceModelGroupedField instance) throws IOException; 085 086 /** 087 * Write an item. 088 * 089 * @param item 090 * the Java object representing the item to write 091 * @param definition 092 * the field instance 093 * @throws IOException 094 * if an error occurred while parsing 095 */ 096 void writeItemField( 097 @NonNull IBoundObject item, 098 @NonNull IBoundDefinitionModelFieldComplex definition) throws IOException; 099 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}