1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.databind.model;
7   
8   import gov.nist.secauto.metaschema.core.model.IBoundObject;
9   import gov.nist.secauto.metaschema.core.util.ObjectUtils;
10  import gov.nist.secauto.metaschema.databind.io.BindingException;
11  import gov.nist.secauto.metaschema.databind.model.info.IFeatureComplexItemValueHandler;
12  import gov.nist.secauto.metaschema.databind.model.info.IItemReadHandler;
13  import gov.nist.secauto.metaschema.databind.model.info.IItemWriteHandler;
14  
15  import java.io.IOException;
16  
17  public interface IBoundInstanceModelFieldComplex
18      extends IBoundInstanceModelField<IBoundObject>, IFeatureComplexItemValueHandler {
19  
20    @Override
21    IBoundDefinitionModelFieldComplex getDefinition();
22  
23    @Override
24    default boolean isEffectiveValueWrappedInXml() {
25      // always wrapped
26      return true;
27    }
28  
29    @Override
30    default IBoundObject readItem(IBoundObject parent, IItemReadHandler handler) throws IOException {
31      return handler.readItemField(ObjectUtils.requireNonNull(parent, "parent"), this);
32    }
33  
34    @Override
35    default void writeItem(IBoundObject item, IItemWriteHandler handler) throws IOException {
36      handler.writeItemField(item, this);
37    }
38  
39    @Override
40    default IBoundObject deepCopyItem(IBoundObject item, IBoundObject parentInstance) throws BindingException {
41      return getDefinition().deepCopyItem(item, parentInstance);
42    }
43  
44    @Override
45    default Class<? extends IBoundObject> getBoundClass() {
46      return getDefinition().getBoundClass();
47    }
48  
49    @Override
50    default void callBeforeDeserialize(IBoundObject targetObject, IBoundObject parentObject) throws BindingException {
51      getDefinition().callBeforeDeserialize(targetObject, parentObject);
52    }
53  
54    @Override
55    default void callAfterDeserialize(IBoundObject targetObject, IBoundObject parentObject) throws BindingException {
56      getDefinition().callAfterDeserialize(targetObject, parentObject);
57    }
58  }