1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.databind.codegen.typeinfo;
7   
8   import com.squareup.javapoet.AnnotationSpec;
9   import com.squareup.javapoet.TypeSpec;
10  
11  import java.util.Set;
12  
13  import dev.metaschema.core.model.IModelDefinition;
14  import edu.umd.cs.findbugs.annotations.NonNull;
15  
16  /**
17   * Provides type information for a grouped named model instance within a choice
18   * group.
19   * <p>
20   * This functional interface is used during code generation to produce the
21   * appropriate annotations and type definitions for members of a choice group.
22   */
23  @FunctionalInterface
24  public interface IGroupedNamedModelInstanceTypeInfo {
25    /**
26     * Generates the member annotation for this grouped instance within the choice
27     * group.
28     *
29     * @param choiceGroupAnnotation
30     *          the annotation builder for the parent choice group
31     * @param typeBuilder
32     *          the type builder for adding any nested type definitions
33     * @param requireExtension
34     *          {@code true} if the generated type must extend a base class,
35     *          {@code false} otherwise
36     * @return a set of model definitions that need to be generated as separate
37     *         classes
38     */
39    @NonNull
40    Set<IModelDefinition> generateMemberAnnotation(
41        @NonNull AnnotationSpec.Builder choiceGroupAnnotation,
42        @NonNull TypeSpec.Builder typeBuilder,
43        boolean requireExtension);
44  }