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 * @param <PARENT_DEFINITION>
021 *          the Java type of the containing assembly definition
022 * @param <FLAG>
023 *          the expected Java type of flag children
024 * @param <MODEL>
025 *          the expected Java type of model children
026 * @param <NAMED_MODEL>
027 *          the expected Java type of named model children
028 * @param <FIELD>
029 *          the expected Java type of field children
030 * @param <ASSEMBLY>
031 *          the expected Java type of assembly children
032 * @param <CHOICE>
033 *          the expected Java type of choice children
034 * @param <CHOICE_GROUP>
035 *          the expected Java type of choice group children
036 */
037public abstract class AbstractInlineAssemblyDefinition<
038    PARENT extends IContainerModel,
039    DEFINITION extends IAssemblyDefinition,
040    INSTANCE extends IAssemblyInstance,
041    PARENT_DEFINITION extends IAssemblyDefinition,
042    FLAG extends IFlagInstance,
043    MODEL extends IModelInstanceAbsolute,
044    NAMED_MODEL extends INamedModelInstanceAbsolute,
045    FIELD extends IFieldInstanceAbsolute,
046    ASSEMBLY extends IAssemblyInstanceAbsolute,
047    CHOICE extends IChoiceInstance,
048    CHOICE_GROUP extends IChoiceGroupInstance>
049    extends AbstractNamedModelInstance<PARENT, PARENT_DEFINITION>
050    implements IAssemblyInstance, IAssemblyDefinition, IFeatureContainerFlag<FLAG>,
051    IFeatureContainerModelAssembly<
052        MODEL,
053        NAMED_MODEL,
054        FIELD,
055        ASSEMBLY,
056        CHOICE,
057        CHOICE_GROUP>,
058    IFeatureDefinitionInstanceInlined<DEFINITION, INSTANCE> {
059
060  /**
061   * Construct a new inline assembly definition.
062   *
063   * @param parent
064   *          the parent model containing this instance
065   */
066  protected AbstractInlineAssemblyDefinition(@NonNull PARENT parent) {
067    super(parent);
068  }
069
070  @Override
071  public final DEFINITION getDefinition() {
072    return ObjectUtils.asType(this);
073  }
074
075  @Override
076  public boolean isInline() {
077    return true;
078  }
079
080  @Override
081  @NonNull
082  public final INSTANCE getInlineInstance() {
083    return ObjectUtils.asType(this);
084  }
085
086  @Override
087  public final FLAG getJsonKey() {
088    return IFeatureContainerFlag.super.getJsonKey();
089  }
090}