001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.databind.model.annotations; 007 008import static java.lang.annotation.RetentionPolicy.RUNTIME; 009 010import java.lang.annotation.Documented; 011import java.lang.annotation.ElementType; 012import java.lang.annotation.Retention; 013import java.lang.annotation.Target; 014 015import dev.metaschema.core.model.JsonGroupAsBehavior; 016import dev.metaschema.core.model.XmlGroupAsBehavior; 017import edu.umd.cs.findbugs.annotations.NonNull; 018 019/** 020 * Defines how a collection of model instances should be grouped. 021 */ 022@Documented 023@Retention(RUNTIME) 024@Target(ElementType.ANNOTATION_TYPE) 025public @interface GroupAs { 026 /** 027 * The name to use for an XML grouping element wrapper or a JSON/YAML grouping 028 * property. 029 * 030 * @return the name 031 */ 032 @NonNull 033 String name(); 034 035 /** 036 * Describes how to handle collections in JSON/YAML. 037 * 038 * @return the JSON collection strategy 039 */ 040 @NonNull 041 JsonGroupAsBehavior inJson() default JsonGroupAsBehavior.SINGLETON_OR_LIST; 042 043 /** 044 * Describes how to handle collections in XML. 045 * 046 * @return the XML collection strategy 047 */ 048 @NonNull 049 XmlGroupAsBehavior inXml() default XmlGroupAsBehavior.UNGROUPED; 050}