001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package dev.metaschema.core.model;
007
008import edu.umd.cs.findbugs.annotations.NonNull;
009
010/**
011 * Represents a field instance that appears within a choice or other grouping
012 * construct.
013 * <p>
014 * Grouped field instances always have XML wrapping enabled and inherit
015 * cardinality from their containing group.
016 */
017public interface IFieldInstanceGrouped extends INamedModelInstanceGrouped, IFieldInstance {
018
019  /**
020   * Determines if the field is configured to have a wrapper in XML.
021   *
022   * @return {@code true} if an XML wrapper is required, or {@code false}
023   *         otherwise
024   */
025  @Override
026  default boolean isInXmlWrapped() {
027    // must always be wrapped
028    return true;
029  }
030
031  @Override
032  default boolean isEffectiveValueWrappedInXml() {
033    // must always be wrapped
034    return true;
035  }
036
037  /**
038   * A visitor callback.
039   *
040   * @param <CONTEXT>
041   *          the type of the context parameter
042   * @param <RESULT>
043   *          the type of the visitor result
044   * @param visitor
045   *          the calling visitor
046   * @param context
047   *          a parameter used to pass contextual information between visitors
048   * @return the visitor result
049   */
050  @Override
051  default <CONTEXT, RESULT> RESULT accept(@NonNull IModelElementVisitor<CONTEXT, RESULT> visitor, CONTEXT context) {
052    return visitor.visitFieldInstance(this, context);
053  }
054}