001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.core.model; 007 008import java.util.Collection; 009 010import edu.umd.cs.findbugs.annotations.NonNull; 011import edu.umd.cs.findbugs.annotations.Nullable; 012 013/** 014 * Indicates that the Metaschema type that has a complex model that can contain 015 * field and assembly instances. 016 */ 017public interface IContainerModel extends IContainer { 018 019 @Override 020 default boolean hasChildren() { 021 return !getModelInstances().isEmpty(); 022 } 023 024 /** 025 * Retrieve the Metaschema module definition containing this container. 026 * 027 * @return the containing Metaschema module definition 028 */ 029 @NonNull 030 IAssemblyDefinition getOwningDefinition(); 031 032 /** 033 * Get all model instances within the container. 034 * 035 * @return an ordered collection of model instances 036 */ 037 @NonNull 038 Collection<? extends IModelInstance> getModelInstances(); 039 040 /** 041 * Get all named model instances within the container. 042 * 043 * @return an ordered mapping of use name to model instance 044 */ 045 @NonNull 046 Collection<? extends INamedModelInstance> getNamedModelInstances(); 047 048 /** 049 * Get the model instance contained within the model with the associated use 050 * name. 051 * 052 * @param index 053 * the effective name-based qualified name index of the model instance 054 * @return the matching model instance, or {@code null} if no match was found 055 * @see INamedModelInstance#getEffectiveName() 056 */ 057 @Nullable 058 INamedModelInstance getNamedModelInstanceByName(Integer index); 059 060 /** 061 * Get all field instances within the container. 062 * 063 * @return a mapping of use name to field instance 064 */ 065 @NonNull 066 Collection<? extends IFieldInstance> getFieldInstances(); 067 068 /** 069 * Get the field instance contained within the model with the associated use 070 * name. 071 * 072 * @param index 073 * the use name-based qualified name index of the field instance 074 * @return the matching field instance, or {@code null} if no match was found 075 * @see IFieldInstance#getUseName() 076 */ 077 @Nullable 078 IFieldInstance getFieldInstanceByName(Integer index); 079 080 /** 081 * Get all assembly instances within the container. 082 * 083 * @return a mapping of use name to assembly instance 084 */ 085 @NonNull 086 Collection<? extends IAssemblyInstance> getAssemblyInstances(); 087 088 /** 089 * Get the assembly instance contained within the model with the associated use 090 * name. 091 * 092 * @param index 093 * the effective name-based qualified name index of the assembly 094 * instance 095 * @return the matching assembly instance, or {@code null} if no match was found 096 * @see INamedModelInstance#getEffectiveName() 097 */ 098 @Nullable 099 IAssemblyInstance getAssemblyInstanceByName(Integer index); 100}