001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_mapping-common_metaschema.xml
002// Do not edit - changes will be lost when regenerated.
003package dev.metaschema.oscal.lib.model;
004
005import dev.metaschema.core.datatype.adapter.DecimalAdapter;
006import dev.metaschema.core.datatype.adapter.StringAdapter;
007import dev.metaschema.core.model.IBoundObject;
008import dev.metaschema.core.model.IMetaschemaData;
009import dev.metaschema.core.model.constraint.IConstraint;
010import dev.metaschema.core.util.ObjectUtils;
011import dev.metaschema.databind.model.annotations.AllowedValue;
012import dev.metaschema.databind.model.annotations.AllowedValues;
013import dev.metaschema.databind.model.annotations.BoundChoice;
014import dev.metaschema.databind.model.annotations.BoundField;
015import dev.metaschema.databind.model.annotations.MetaschemaAssembly;
016import dev.metaschema.databind.model.annotations.ValueConstraints;
017import edu.umd.cs.findbugs.annotations.Nullable;
018import java.math.BigDecimal;
019import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
020import org.apache.commons.lang3.builder.ToStringStyle;
021
022/**
023 * This records either a string category or a decimal value from 0-1 representing a percentage. Both of these values describe an estimation of the author's confidence that this mapping is correct and accurate.
024 */
025@MetaschemaAssembly(
026    formalName = "Confidence Score",
027    description = "This records either a string category or a decimal value from 0-1 representing a percentage. Both of these values describe an estimation of the author's confidence that this mapping is correct and accurate.",
028    name = "confidence-score",
029    moduleClass = OscalMappingCommonModule.class
030)
031public class ConfidenceScore implements IBoundObject {
032  private final IMetaschemaData __metaschemaData;
033
034  @BoundField(
035      useName = "category",
036      typeAdapter = StringAdapter.class,
037      valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, target = ".[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]", allowOthers = true, values = {@AllowedValue(value = "unspecified", description = "No category is specified for the confidence score."), @AllowedValue(value = "high", description = "High confidence in the mapping."), @AllowedValue(value = "medium", description = "Medium confidence in the mapping."), @AllowedValue(value = "low", description = "Low confidence in the mapping.")}))
038  )
039  @BoundChoice(
040      choiceId = "choice-1"
041  )
042  private String _category;
043
044  /**
045   * A decimal value from 0-1, representing a percentage.
046   */
047  @BoundField(
048      formalName = "Percentage",
049      description = "A decimal value from 0-1, representing a percentage.",
050      useName = "percentage",
051      typeAdapter = DecimalAdapter.class
052  )
053  @BoundChoice(
054      choiceId = "choice-1"
055  )
056  private BigDecimal _percentage;
057
058  /**
059   * Constructs a new {@code dev.metaschema.oscal.lib.model.ConfidenceScore} instance with no metadata.
060   */
061  public ConfidenceScore() {
062    this(null);
063  }
064
065  /**
066   * Constructs a new {@code dev.metaschema.oscal.lib.model.ConfidenceScore} instance with the specified metadata.
067   *
068   * @param data
069   *           the metaschema data, or {@code null} if none
070   */
071  public ConfidenceScore(IMetaschemaData data) {
072    this.__metaschemaData = data;
073  }
074
075  @Override
076  public IMetaschemaData getMetaschemaData() {
077    return __metaschemaData;
078  }
079
080  /**
081   * Get the {@code category} property.
082   *
083   * @return the category value, or {@code null} if not set
084   */
085  @Nullable
086  public String getCategory() {
087    return _category;
088  }
089
090  /**
091   * Set the {@code category} property.
092   *
093   * @param value
094   *           the category value to set, or {@code null} to clear
095   */
096  public void setCategory(@Nullable String value) {
097    _category = value;
098  }
099
100  /**
101   * Get the "{@literal Percentage}".
102   *
103   * <p>
104   * A decimal value from 0-1, representing a percentage.
105   *
106   * @return the percentage value, or {@code null} if not set
107   */
108  @Nullable
109  public BigDecimal getPercentage() {
110    return _percentage;
111  }
112
113  /**
114   * Set the "{@literal Percentage}".
115   *
116   * <p>
117   * A decimal value from 0-1, representing a percentage.
118   *
119   * @param value
120   *           the percentage value to set, or {@code null} to clear
121   */
122  public void setPercentage(@Nullable BigDecimal value) {
123    _percentage = value;
124  }
125
126  @Override
127  public String toString() {
128    return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString());
129  }
130}