1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.core.model;
7   
8   import java.util.Collection;
9   
10  import javax.xml.namespace.QName;
11  
12  import edu.umd.cs.findbugs.annotations.NonNull;
13  
14  /**
15   * Common interface for model container support classes.
16   *
17   * @param <MI>
18   *          the model instance Java type
19   * @param <NMI>
20   *          the named model instance Java type
21   * @param <FI>
22   *          the field instance Java type
23   * @param <AI>
24   *          the assembly instance Java type
25   */
26  public interface IFeatureContainerModel<
27      MI extends IModelInstance,
28      NMI extends INamedModelInstance,
29      FI extends IFieldInstance,
30      AI extends IAssemblyInstance>
31      extends IContainerModel {
32    /**
33     * Get the model container implementation instance.
34     *
35     * @return the model container instance
36     */
37    @NonNull
38    IContainerModelSupport<MI, NMI, FI, AI> getModelContainer();
39  
40    @Override
41    default Collection<MI> getModelInstances() {
42      return getModelContainer().getModelInstances();
43    }
44  
45    @Override
46    default NMI getNamedModelInstanceByName(QName name) {
47      return getModelContainer().getNamedModelInstanceMap().get(name);
48    }
49  
50    @SuppressWarnings("null")
51    @Override
52    default Collection<NMI> getNamedModelInstances() {
53      return getModelContainer().getNamedModelInstanceMap().values();
54    }
55  
56    @Override
57    default FI getFieldInstanceByName(QName name) {
58      return getModelContainer().getFieldInstanceMap().get(name);
59    }
60  
61    @SuppressWarnings("null")
62    @Override
63    default Collection<FI> getFieldInstances() {
64      return getModelContainer().getFieldInstanceMap().values();
65    }
66  
67    @Override
68    default AI getAssemblyInstanceByName(QName name) {
69      return getModelContainer().getAssemblyInstanceMap().get(name);
70    }
71  
72    @SuppressWarnings("null")
73    @Override
74    default Collection<AI> getAssemblyInstances() {
75      return getModelContainer().getAssemblyInstanceMap().values();
76    }
77  }