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 */
025public abstract class AbstractInlineFieldDefinition<
026    PARENT extends IContainerModel,
027    DEFINITION extends IFieldDefinition,
028    INSTANCE extends IFieldInstance,
029    PARENT_DEFINITION extends IAssemblyDefinition,
030    FLAG extends IFlagInstance>
031    extends AbstractNamedModelInstance<PARENT, PARENT_DEFINITION>
032    implements IFieldInstance, IFieldDefinition,
033    IFeatureContainerFlag<FLAG>,
034    IFeatureDefinitionInstanceInlined<DEFINITION, INSTANCE> {
035
036  /**
037   * Construct a new inline assembly definition.
038   *
039   * @param parent
040   *          the parent model containing this instance
041   */
042  protected AbstractInlineFieldDefinition(@NonNull PARENT parent) {
043    super(parent);
044  }
045
046  @Override
047  public final DEFINITION getDefinition() {
048    return ObjectUtils.asType(this);
049  }
050
051  @Override
052  public boolean isInline() {
053    return true;
054  }
055
056  @Override
057  @NonNull
058  public final INSTANCE getInlineInstance() {
059    return ObjectUtils.asType(this);
060  }
061
062  @Override
063  public final FLAG getJsonKey() {
064    return IFeatureContainerFlag.super.getJsonKey();
065  }
066}