001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package dev.metaschema.core.model;
007
008import dev.metaschema.core.util.ObjectUtils;
009import edu.umd.cs.findbugs.annotations.NonNull;
010
011/**
012 * A base class for an assembly instance defined inline.
013 *
014 * @param <PARENT>
015 *          the Java type of the parent model container for this instance
016 * @param <DEFINITION>
017 *          the Java type of the related assembly definition
018 * @param <INSTANCE>
019 *          the expected Java type of an instance of this definition
020 */
021public abstract class AbstractInlineFlagDefinition<
022    PARENT extends IModelDefinition,
023    DEFINITION extends IFlagDefinition,
024    INSTANCE extends IFlagInstance>
025    extends AbstractFlagInstance<PARENT, DEFINITION, INSTANCE>
026    implements IFlagDefinition,
027    IFeatureDefinitionInstanceInlined<DEFINITION, INSTANCE> {
028
029  /**
030   * Construct a new inline assembly definition.
031   *
032   * @param parent
033   *          the parent model containing this instance
034   */
035  protected AbstractInlineFlagDefinition(@NonNull PARENT parent) {
036    super(parent);
037  }
038
039  @Override
040  public final DEFINITION getDefinition() {
041    return ObjectUtils.asType(this);
042  }
043
044  @Override
045  @NonNull
046  public final INSTANCE getInlineInstance() {
047    return ObjectUtils.asType(this);
048  }
049
050  /**
051   * A visitor callback.
052   *
053   * @param <CONTEXT>
054   *          the type of the context parameter
055   * @param <RESULT>
056   *          the type of the visitor result
057   * @param visitor
058   *          the calling visitor
059   * @param context
060   *          a parameter used to pass contextual information between visitors
061   * @return the visitor result
062   */
063  @Override
064  public <CONTEXT, RESULT> RESULT accept(@NonNull IModelElementVisitor<CONTEXT, RESULT> visitor, CONTEXT context) {
065    return visitor.visitFlagInstance(this, context);
066  }
067}