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