1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.model.constraint;
7   
8   import dev.metaschema.core.datatype.markup.MarkupLine;
9   import dev.metaschema.core.model.constraint.impl.DefaultAllowedValue;
10  import edu.umd.cs.findbugs.annotations.NonNull;
11  import edu.umd.cs.findbugs.annotations.Nullable;
12  
13  /**
14   * Represents an individual enumerated value associated with an
15   * {@link IAllowedValuesConstraint}.
16   * <p>
17   * These values are part of a collection of values in an
18   * {@link IAllowedValuesConstraint}.
19   */
20  public interface IAllowedValue {
21    /**
22     * Construct a new allowed value entry for use in an
23     * {@link IAllowedValuesConstraint}.
24     *
25     * @param value
26     *          the allowed value
27     * @param description
28     *          a textual description of the value
29     * @param deprecatedVersion
30     *          the version this value was deprecated in
31     * @return the new allowed value
32     */
33    @NonNull
34    static IAllowedValue of(
35        @NonNull String value,
36        @NonNull MarkupLine description,
37        @Nullable String deprecatedVersion) {
38      return new DefaultAllowedValue(value, description, deprecatedVersion);
39    }
40  
41    /**
42     * Retrieves the enumerated value associated with this allowed value constraint
43     * entry.
44     *
45     * @return the value
46     */
47    @NonNull
48    String getValue();
49  
50    /**
51     * If the value is deprecated, get the deprecated version.
52     *
53     * @return the deprecated version or {@code null} if the value is not deprecated
54     */
55    String getDeprecatedVersion();
56  
57    /**
58     * Retrieves the enumerated value's description associated with this allowed
59     * value constraint entry.
60     *
61     * @return the description
62     */
63    @NonNull
64    MarkupLine getDescription();
65  }