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 * A base class for a choice that is a member of a containing model.
012 *
013 * @param <PARENT>
014 *          the Java type of the containing assembly definition
015 * @param <MODEL>
016 *          the Java type of child model instances supported by this choice
017 * @param <NAMED_MODEL>
018 *          the Java type of child named model instances supported by this
019 *          choice
020 * @param <FIELD>
021 *          the Java type of child field instances supported by this choice
022 * @param <ASSEMBLY>
023 *          the Java type of child assembly instances supported by this choice
024 */
025public abstract class AbstractChoiceInstance<
026    PARENT extends IAssemblyDefinition,
027    MODEL extends IModelInstanceAbsolute,
028    NAMED_MODEL extends INamedModelInstanceAbsolute,
029    FIELD extends IFieldInstanceAbsolute,
030    ASSEMBLY extends IAssemblyInstanceAbsolute>
031    extends AbstractInstance<PARENT>
032    implements IChoiceInstance, IFeatureContainerModelAbsolute<MODEL, NAMED_MODEL, FIELD, ASSEMBLY> {
033
034  /**
035   * Construct a new choice instance that is contained with the provided parent
036   * assembly definition.
037   *
038   * @param parent
039   *          the parent assembly definition container for this instance
040   */
041  protected AbstractChoiceInstance(@NonNull PARENT parent) {
042    super(parent);
043  }
044
045  @Override
046  public String getGroupAsName() {
047    // a choice does not have a groups-as name
048    return null;
049  }
050
051  /**
052   * Retrieve the Metaschema assembly definition on which this instance is
053   * declared.
054   *
055   * @return the parent Metaschema assembly definition
056   */
057  @Override
058  public PARENT getContainingDefinition() {
059    return getParentContainer();
060  }
061
062  @Override
063  public IModule getContainingModule() {
064    return getParentContainer().getContainingModule();
065  }
066}