1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.databind.model.annotations;
7   
8   import static java.lang.annotation.RetentionPolicy.RUNTIME;
9   
10  import java.lang.annotation.Documented;
11  import java.lang.annotation.ElementType;
12  import java.lang.annotation.Retention;
13  import java.lang.annotation.Target;
14  
15  import dev.metaschema.core.model.JsonGroupAsBehavior;
16  import dev.metaschema.core.model.XmlGroupAsBehavior;
17  import edu.umd.cs.findbugs.annotations.NonNull;
18  
19  /**
20   * Defines how a collection of model instances should be grouped.
21   */
22  @Documented
23  @Retention(RUNTIME)
24  @Target(ElementType.ANNOTATION_TYPE)
25  public @interface GroupAs {
26    /**
27     * The name to use for an XML grouping element wrapper or a JSON/YAML grouping
28     * property.
29     *
30     * @return the name
31     */
32    @NonNull
33    String name();
34  
35    /**
36     * Describes how to handle collections in JSON/YAML.
37     *
38     * @return the JSON collection strategy
39     */
40    @NonNull
41    JsonGroupAsBehavior inJson() default JsonGroupAsBehavior.SINGLETON_OR_LIST;
42  
43    /**
44     * Describes how to handle collections in XML.
45     *
46     * @return the XML collection strategy
47     */
48    @NonNull
49    XmlGroupAsBehavior inXml() default XmlGroupAsBehavior.UNGROUPED;
50  }