001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package gov.nist.secauto.metaschema.databind.model.annotations;
007
008import static java.lang.annotation.ElementType.FIELD;
009import static java.lang.annotation.ElementType.METHOD;
010import static java.lang.annotation.RetentionPolicy.RUNTIME;
011
012import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter;
013import gov.nist.secauto.metaschema.core.model.IBoundObject;
014
015import java.lang.annotation.Documented;
016import java.lang.annotation.Retention;
017import java.lang.annotation.Target;
018
019import edu.umd.cs.findbugs.annotations.NonNull;
020
021/**
022 * Identifies that the annotation target is a bound property that references a
023 * Module field.
024 * <p>
025 * For XML serialization, the {@link #useName()} identifies the name of the
026 * element to use for this element.
027 * <p>
028 * For JSON and YAML serializations, the {@link #useName()} identifies the
029 * property/item name to use.
030 * <p>
031 * The field must be either:
032 * <ol>
033 * <li>A Module data type or a collection whose item value is Module data type,
034 * with a non-null {@link #typeAdapter()}.
035 * <li>A type or a collection whose item value is a type based on a class with a
036 * {@link MetaschemaField} annotation, with a property annotated with
037 * {@link BoundFieldValue}.</li>
038 * </ol>
039 */
040@Documented
041@Retention(RUNTIME)
042@Target({ FIELD, METHOD })
043public @interface BoundGroupedField {
044  /**
045   * Get the documentary formal name of the field.
046   * <p>
047   * If the value is "##none", then the description will be considered
048   * {@code null}.
049   *
050   * @return a markdown string or {@code "##none"} if no formal name is provided
051   */
052  @NonNull
053  String formalName() default ModelUtil.NO_STRING_VALUE;
054
055  /**
056   * Get the documentary description of the field.
057   * <p>
058   * If the value is "##none", then the description will be considered
059   * {@code null}.
060   *
061   * @return a markdown string or {@code "##none"} if no description is provided
062   */
063  @NonNull
064  String description() default ModelUtil.NO_STRING_VALUE;
065
066  /**
067   * The model name to use for JSON/YAML singleton values and associated XML
068   * elements.
069   * <p>
070   * If the value is "##none", then the use name will be provided by the
071   * definition or by the field name if the item value class is missing the
072   * {@link MetaschemaField} annotation.
073   *
074   * @return the name
075   */
076  @NonNull
077  String useName() default ModelUtil.NO_STRING_VALUE;
078
079  /**
080   * The binary use name of the field.
081   * <p>
082   * The value {@link Integer#MIN_VALUE} indicates that there is no use name.
083   *
084   * @return the index value
085   */
086  int useIndex() default Integer.MIN_VALUE;
087
088  /**
089   * The Metaschema data type adapter for the field's value.
090   *
091   * @return the data type adapter
092   */
093  @NonNull
094  Class<? extends IDataTypeAdapter<?>> typeAdapter() default NullJavaTypeAdapter.class;
095
096  /**
097   * An optional set of associated properties.
098   *
099   * @return the properties or an empty array with no properties
100   */
101  Property[] properties() default {};
102
103  /**
104   * Get any remarks for this field.
105   *
106   * @return a markdown string or {@code "##none"} if no remarks are provided
107   */
108  @NonNull
109  String remarks() default ModelUtil.NO_STRING_VALUE;
110
111  /**
112   * Get the value constraints defined for this Metaschema field inline
113   * definition.
114   *
115   * @return the value constraints
116   */
117  ValueConstraints valueConstraints() default @ValueConstraints;
118
119  /**
120   * Get any remarks for this field.
121   *
122   * @return the discriminator string or {@code "##none"} if no discriminator is
123   *         provided
124   */
125  @NonNull
126  String discriminatorValue() default ModelUtil.NO_STRING_VALUE;
127
128  /**
129   * The bound class associated with this assembly.
130   * <p>
131   * This is optional when used on a field or method, and required when used with
132   * an annotation type value, i.e. {@link BoundChoiceGroup}.
133   *
134   * @return the bound class
135   */
136  @NonNull
137  Class<? extends IBoundObject> binding();
138}