001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 004import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag; 006import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 007import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 008import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 009import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter; 010import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 011import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 012import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 013import java.lang.Override; 014import java.lang.String; 015import java.util.LinkedList; 016import java.util.List; 017import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 018import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 019 020/** 021 * Identifies the parameter that will be set by the enclosed value. 022 */ 023@MetaschemaAssembly( 024 formalName = "Set Parameter Value", 025 description = "Identifies the parameter that will be set by the enclosed value.", 026 name = "set-parameter", 027 metaschema = OscalImplementationCommonMetaschema.class 028) 029public class SetParameter { 030 @BoundFlag( 031 formalName = "Parameter ID", 032 description = "A [human-oriented](https://pages.nist.gov/OSCAL/concepts/identifier-use/#human-oriented) reference to a `parameter` within a control, who's catalog has been imported into the current implementation context.", 033 useName = "param-id", 034 required = true, 035 typeAdapter = TokenAdapter.class 036 ) 037 private String _paramId; 038 039 /** 040 * "A parameter value or set of values." 041 */ 042 @BoundField( 043 formalName = "Parameter Value", 044 description = "A parameter value or set of values.", 045 useName = "value", 046 minOccurs = 1, 047 maxOccurs = -1 048 ) 049 @GroupAs( 050 name = "values", 051 inJson = JsonGroupAsBehavior.LIST 052 ) 053 private List<String> _values; 054 055 @BoundField( 056 formalName = "Remarks", 057 description = "Additional commentary about the containing object.", 058 useName = "remarks" 059 ) 060 @BoundFieldValue( 061 typeAdapter = MarkupMultilineAdapter.class 062 ) 063 private MarkupMultiline _remarks; 064 065 public SetParameter() { 066 } 067 068 public String getParamId() { 069 return _paramId; 070 } 071 072 public void setParamId(String value) { 073 _paramId = value; 074 } 075 076 public List<String> getValues() { 077 return _values; 078 } 079 080 public void setValues(List<String> value) { 081 _values = value; 082 } 083 084 /** 085 * Add a new {@link String} item to the underlying collection. 086 * @param item the item to add 087 * @return {@code true} 088 */ 089 public boolean addValue(String item) { 090 String value = ObjectUtils.requireNonNull(item,"item cannot be null"); 091 if (_values == null) { 092 _values = new LinkedList<>(); 093 } 094 return _values.add(value); 095 } 096 097 /** 098 * Remove the first matching {@link String} item from the underlying collection. 099 * @param item the item to remove 100 * @return {@code true} if the item was removed or {@code false} otherwise 101 */ 102 public boolean removeValue(String item) { 103 String value = ObjectUtils.requireNonNull(item,"item cannot be null"); 104 return _values == null ? false : _values.remove(value); 105 } 106 107 public MarkupMultiline getRemarks() { 108 return _remarks; 109 } 110 111 public void setRemarks(MarkupMultiline value) { 112 _remarks = value; 113 } 114 115 @Override 116 public String toString() { 117 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 118 } 119}