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