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.ElementType.FIELD;
009import static java.lang.annotation.ElementType.METHOD;
010import static java.lang.annotation.RetentionPolicy.RUNTIME;
011
012import java.lang.annotation.Documented;
013import java.lang.annotation.Retention;
014import java.lang.annotation.Target;
015
016import dev.metaschema.core.datatype.IDataTypeAdapter;
017import edu.umd.cs.findbugs.annotations.NonNull;
018
019/**
020 * Identifies a field on a class annotated with the {@link MetaschemaField}
021 * annotation as the Module field's value.
022 */
023// TODO: how are index names handled here?
024@Documented
025@Retention(RUNTIME)
026@Target({ FIELD, METHOD })
027public @interface BoundFieldValue {
028  /**
029   * The Module data type adapter for the field's value.
030   *
031   * @return the data type adapter
032   */
033  @NonNull
034  Class<? extends IDataTypeAdapter<?>> typeAdapter() default NullJavaTypeAdapter.class;
035
036  /**
037   * The default value of the field represented as a string.
038   * <p>
039   * The value {@link ModelUtil#NULL_VALUE} is used to indicate if no default
040   * value is provided.
041   *
042   * @return the default value
043   */
044  @NonNull
045  String defaultValue() default ModelUtil.NULL_VALUE;
046
047  /**
048   * The name of the JSON property that contains the field's value. If this value
049   * is provided, the the name will be used as the property name. Otherwise, the
050   * property name will default to a value defined by the data type.
051   * <p>
052   * Use of this annotation is mutually exclusive with the
053   * {@link JsonFieldValueKeyFlag} annotation.
054   *
055   * @return the name
056   */
057  @NonNull
058  String valueKeyName() default ModelUtil.NO_STRING_VALUE;
059}