1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.databind.model.annotations;
7   
8   import static java.lang.annotation.ElementType.FIELD;
9   import static java.lang.annotation.ElementType.METHOD;
10  import static java.lang.annotation.RetentionPolicy.RUNTIME;
11  
12  import gov.nist.secauto.metaschema.core.datatype.IDataTypeAdapter;
13  
14  import java.lang.annotation.Documented;
15  import java.lang.annotation.Retention;
16  import java.lang.annotation.Target;
17  
18  import edu.umd.cs.findbugs.annotations.NonNull;
19  
20  /**
21   * Identifies a field on a class annotated with the {@link MetaschemaField}
22   * annotation as the Module field's value.
23   */
24  // TODO: how are index names handled here?
25  @Documented
26  @Retention(RUNTIME)
27  @Target({ FIELD, METHOD })
28  public @interface BoundFieldValue {
29    /**
30     * The Module data type adapter for the field's value.
31     *
32     * @return the data type adapter
33     */
34    @NonNull
35    Class<? extends IDataTypeAdapter<?>> typeAdapter() default NullJavaTypeAdapter.class;
36  
37    /**
38     * The default value of the field represented as a string.
39     * <p>
40     * The value {@link ModelUtil#NULL_VALUE} is used to indicate if no default
41     * value is provided.
42     *
43     * @return the default value
44     */
45    @NonNull
46    String defaultValue() default ModelUtil.NULL_VALUE;
47  
48    /**
49     * The name of the JSON property that contains the field's value. If this value
50     * is provided, the the name will be used as the property name. Otherwise, the
51     * property name will default to a value defined by the data type.
52     * <p>
53     * Use of this annotation is mutually exclusive with the
54     * {@link JsonFieldValueKeyFlag} annotation.
55     *
56     * @return the name
57     */
58    @NonNull
59    String valueKeyName() default ModelUtil.NO_STRING_VALUE;
60  }