1 package gov.nist.secauto.oscal.lib.model;
2
3 import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue;
4 import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues;
5 import gov.nist.secauto.metaschema.binding.model.annotations.BoundField;
6 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue;
7 import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag;
8 import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs;
9 import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
10 import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints;
11 import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior;
12 import gov.nist.secauto.metaschema.model.common.constraint.IConstraint;
13 import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter;
14 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLine;
15 import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupLineAdapter;
16 import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
17 import java.lang.Override;
18 import java.lang.String;
19 import java.util.LinkedList;
20 import java.util.List;
21 import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
22 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
23
24
25
26
27 @MetaschemaAssembly(
28 formalName = "Selection",
29 description = "Presenting a choice among alternatives.",
30 name = "parameter-selection",
31 metaschema = OscalControlCommonMetaschema.class,
32 remarks = "A set of parameter value choices, that may be picked from to set the parameter value."
33 )
34 public class ParameterSelection {
35 @BoundFlag(
36 formalName = "Parameter Cardinality",
37 description = "Describes the number of selections that must occur. Without this setting, only one value should be assumed to be permitted.",
38 useName = "how-many",
39 typeAdapter = TokenAdapter.class
40 )
41 @ValueConstraints(
42 allowedValues = @AllowedValues(level = IConstraint.Level.ERROR, values = {@AllowedValue(value = "one", description = "Only one value is permitted."), @AllowedValue(value = "one-or-more", description = "One or more values are permitted.")})
43 )
44 private String _howMany;
45
46
47
48
49 @BoundField(
50 formalName = "Choice",
51 description = "A value selection among several such options.",
52 useName = "choice",
53 maxOccurs = -1
54 )
55 @BoundFieldValue(
56 typeAdapter = MarkupLineAdapter.class
57 )
58 @GroupAs(
59 name = "choice",
60 inJson = JsonGroupAsBehavior.LIST
61 )
62 private List<MarkupLine> _choice;
63
64 public ParameterSelection() {
65 }
66
67 public String getHowMany() {
68 return _howMany;
69 }
70
71 public void setHowMany(String value) {
72 _howMany = value;
73 }
74
75 public List<MarkupLine> getChoice() {
76 return _choice;
77 }
78
79 public void setChoice(List<MarkupLine> value) {
80 _choice = value;
81 }
82
83
84
85
86
87
88 public boolean addChoice(MarkupLine item) {
89 MarkupLine value = ObjectUtils.requireNonNull(item,"item cannot be null");
90 if (_choice == null) {
91 _choice = new LinkedList<>();
92 }
93 return _choice.add(value);
94 }
95
96
97
98
99
100
101 public boolean removeChoice(MarkupLine item) {
102 MarkupLine value = ObjectUtils.requireNonNull(item,"item cannot be null");
103 return _choice == null ? false : _choice.remove(value);
104 }
105
106 @Override
107 public String toString() {
108 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
109 }
110 }