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