1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.model.constraint.impl;
7   
8   import dev.metaschema.core.datatype.markup.MarkupLine;
9   import dev.metaschema.core.model.constraint.IAllowedValue;
10  import dev.metaschema.core.model.constraint.IAllowedValuesConstraint;
11  import edu.umd.cs.findbugs.annotations.NonNull;
12  import edu.umd.cs.findbugs.annotations.Nullable;
13  
14  /**
15   * Organizes information for a single allowed value in a set of allowed values.
16   */
17  public class DefaultAllowedValue implements IAllowedValue {
18    @NonNull
19    private final String value;
20    @NonNull
21    private final MarkupLine description;
22    @Nullable
23    private final String deprecatedVersion;
24  
25    /**
26     * Construct a new allowed value entry for use in an
27     * {@link IAllowedValuesConstraint}.
28     *
29     * @param value
30     *          the allowed value
31     * @param description
32     *          a textual description of the value
33     * @param deprecatedVersion
34     *          the module version this value was deprecated in or {@code null} if
35     *          the value is not deprecated
36     */
37    public DefaultAllowedValue(
38        @NonNull String value,
39        @NonNull MarkupLine description,
40        @Nullable String deprecatedVersion) {
41      this.value = value;
42      this.description = description;
43      this.deprecatedVersion = deprecatedVersion;
44    }
45  
46    @Override
47    public String getValue() {
48      return value;
49    }
50  
51    @Override
52    public MarkupLine getDescription() {
53      return description;
54    }
55  
56    @Override
57    public String getDeprecatedVersion() {
58      return deprecatedVersion;
59    }
60  }