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