001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package gov.nist.secauto.metaschema.databind.model;
007
008import gov.nist.secauto.metaschema.core.model.IBoundObject;
009import gov.nist.secauto.metaschema.core.util.ObjectUtils;
010import gov.nist.secauto.metaschema.databind.io.BindingException;
011import gov.nist.secauto.metaschema.databind.model.info.IFeatureComplexItemValueHandler;
012import gov.nist.secauto.metaschema.databind.model.info.IItemReadHandler;
013import gov.nist.secauto.metaschema.databind.model.info.IItemWriteHandler;
014
015import java.io.IOException;
016
017public interface IBoundInstanceModelFieldComplex
018    extends IBoundInstanceModelField<IBoundObject>, IFeatureComplexItemValueHandler {
019
020  @Override
021  IBoundDefinitionModelFieldComplex getDefinition();
022
023  @Override
024  default boolean isEffectiveValueWrappedInXml() {
025    // always wrapped
026    return true;
027  }
028
029  @Override
030  default IBoundObject readItem(IBoundObject parent, IItemReadHandler handler) throws IOException {
031    return handler.readItemField(ObjectUtils.requireNonNull(parent, "parent"), this);
032  }
033
034  @Override
035  default void writeItem(IBoundObject item, IItemWriteHandler handler) throws IOException {
036    handler.writeItemField(item, this);
037  }
038
039  @Override
040  default IBoundObject deepCopyItem(IBoundObject item, IBoundObject parentInstance) throws BindingException {
041    return getDefinition().deepCopyItem(item, parentInstance);
042  }
043
044  @Override
045  default Class<? extends IBoundObject> getBoundClass() {
046    return getDefinition().getBoundClass();
047  }
048
049  @Override
050  default void callBeforeDeserialize(IBoundObject targetObject, IBoundObject parentObject) throws BindingException {
051    getDefinition().callBeforeDeserialize(targetObject, parentObject);
052  }
053
054  @Override
055  default void callAfterDeserialize(IBoundObject targetObject, IBoundObject parentObject) throws BindingException {
056    getDefinition().callAfterDeserialize(targetObject, parentObject);
057  }
058}