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  import edu.umd.cs.findbugs.annotations.Nullable;
14  
15  /**
16   * Indicates that the Metaschema type that has a complex model that can contain
17   * field and assembly instances.
18   */
19  public interface IContainerModel extends IContainer {
20  
21    @Override
22    default boolean hasChildren() {
23      return !getModelInstances().isEmpty();
24    }
25  
26    /**
27     * Retrieve the Metaschema module definition containing this container.
28     *
29     * @return the containing Metaschema module definition
30     */
31    @NonNull
32    IAssemblyDefinition getOwningDefinition();
33  
34    /**
35     * Get all model instances within the container.
36     *
37     * @return an ordered collection of model instances
38     */
39    @NonNull
40    Collection<? extends IModelInstance> getModelInstances();
41  
42    /**
43     * Get all named model instances within the container.
44     *
45     * @return an ordered mapping of use name to model instance
46     */
47    @NonNull
48    Collection<? extends INamedModelInstance> getNamedModelInstances();
49  
50    /**
51     * Get the model instance contained within the model with the associated use
52     * name.
53     *
54     * @param name
55     *          the effective name of the model instance
56     * @return the matching model instance, or {@code null} if no match was found
57     * @see INamedModelInstance#getEffectiveName()
58     */
59    @Nullable
60    INamedModelInstance getNamedModelInstanceByName(QName name);
61  
62    /**
63     * Get all field instances within the container.
64     *
65     * @return a mapping of use name to field instance
66     */
67    @NonNull
68    Collection<? extends IFieldInstance> getFieldInstances();
69  
70    /**
71     * Get the field instance contained within the model with the associated use
72     * name.
73     *
74     * @param name
75     *          the use name of the field instance
76     * @return the matching field instance, or {@code null} if no match was found
77     * @see IFieldInstance#getUseName()
78     */
79    @Nullable
80    IFieldInstance getFieldInstanceByName(QName name);
81  
82    /**
83     * Get all assembly instances within the container.
84     *
85     * @return a mapping of use name to assembly instance
86     */
87    @NonNull
88    Collection<? extends IAssemblyInstance> getAssemblyInstances();
89  
90    /**
91     * Get the assembly instance contained within the model with the associated use
92     * name.
93     *
94     * @param name
95     *          the effective name of the assembly instance
96     * @return the matching assembly instance, or {@code null} if no match was found
97     * @see INamedModelInstance#getEffectiveName()
98     */
99    @Nullable
100   IAssemblyInstance getAssemblyInstanceByName(QName name);
101 }