View Javadoc
1   package gov.nist.secauto.oscal.lib.model;
2   
3   import gov.nist.secauto.metaschema.binding.model.annotations.AssemblyConstraints;
4   import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly;
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.GroupAs;
8   import gov.nist.secauto.metaschema.binding.model.annotations.IsUnique;
9   import gov.nist.secauto.metaschema.binding.model.annotations.KeyField;
10  import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly;
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.markup.MarkupMultiline;
14  import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter;
15  import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
16  import java.lang.Override;
17  import java.lang.String;
18  import java.util.LinkedList;
19  import java.util.List;
20  import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle;
21  import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
22  
23  /**
24   * A description of the logical flow of information within the system and across its boundaries, optionally supplemented by diagrams that illustrate these flows.
25   */
26  @MetaschemaAssembly(
27      formalName = "Data Flow",
28      description = "A description of the logical flow of information within the system and across its boundaries, optionally supplemented by diagrams that illustrate these flows.",
29      name = "data-flow",
30      metaschema = OscalSspMetaschema.class
31  )
32  @AssemblyConstraints(
33      isUnique = @IsUnique(id = "unique-ssp-data-flow-diagram", level = IConstraint.Level.ERROR, target = "diagram", keyFields = @KeyField(target = "@uuid"), remarks = "A given `uuid` must be assigned only once to a diagram.")
34  )
35  public class DataFlow {
36    /**
37     * "A summary of the system's data flow."
38     */
39    @BoundField(
40        formalName = "Data Flow Description",
41        description = "A summary of the system's data flow.",
42        useName = "description",
43        minOccurs = 1
44    )
45    @BoundFieldValue(
46        typeAdapter = MarkupMultilineAdapter.class
47    )
48    private MarkupMultiline _description;
49  
50    @BoundAssembly(
51        formalName = "Property",
52        description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.",
53        useName = "prop",
54        maxOccurs = -1
55    )
56    @GroupAs(
57        name = "props",
58        inJson = JsonGroupAsBehavior.LIST
59    )
60    private List<Property> _props;
61  
62    @BoundAssembly(
63        formalName = "Link",
64        description = "A reference to a local or remote resource, that has a specific relation to the containing object.",
65        useName = "link",
66        maxOccurs = -1
67    )
68    @GroupAs(
69        name = "links",
70        inJson = JsonGroupAsBehavior.LIST
71    )
72    private List<Link> _links;
73  
74    @BoundAssembly(
75        formalName = "Diagram",
76        description = "A graphic that provides a visual representation the system, or some aspect of it.",
77        useName = "diagram",
78        maxOccurs = -1
79    )
80    @GroupAs(
81        name = "diagrams",
82        inJson = JsonGroupAsBehavior.LIST
83    )
84    private List<Diagram> _diagrams;
85  
86    @BoundField(
87        formalName = "Remarks",
88        description = "Additional commentary about the containing object.",
89        useName = "remarks"
90    )
91    @BoundFieldValue(
92        typeAdapter = MarkupMultilineAdapter.class
93    )
94    private MarkupMultiline _remarks;
95  
96    public DataFlow() {
97    }
98  
99    public MarkupMultiline getDescription() {
100     return _description;
101   }
102 
103   public void setDescription(MarkupMultiline value) {
104     _description = value;
105   }
106 
107   public List<Property> getProps() {
108     return _props;
109   }
110 
111   public void setProps(List<Property> value) {
112     _props = value;
113   }
114 
115   /**
116    * Add a new {@link Property} item to the underlying collection.
117    * @param item the item to add
118    * @return {@code true}
119    */
120   public boolean addProp(Property item) {
121     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
122     if (_props == null) {
123       _props = new LinkedList<>();
124     }
125     return _props.add(value);
126   }
127 
128   /**
129    * Remove the first matching {@link Property} item from the underlying collection.
130    * @param item the item to remove
131    * @return {@code true} if the item was removed or {@code false} otherwise
132    */
133   public boolean removeProp(Property item) {
134     Property value = ObjectUtils.requireNonNull(item,"item cannot be null");
135     return _props == null ? false : _props.remove(value);
136   }
137 
138   public List<Link> getLinks() {
139     return _links;
140   }
141 
142   public void setLinks(List<Link> value) {
143     _links = value;
144   }
145 
146   /**
147    * Add a new {@link Link} item to the underlying collection.
148    * @param item the item to add
149    * @return {@code true}
150    */
151   public boolean addLink(Link item) {
152     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
153     if (_links == null) {
154       _links = new LinkedList<>();
155     }
156     return _links.add(value);
157   }
158 
159   /**
160    * Remove the first matching {@link Link} item from the underlying collection.
161    * @param item the item to remove
162    * @return {@code true} if the item was removed or {@code false} otherwise
163    */
164   public boolean removeLink(Link item) {
165     Link value = ObjectUtils.requireNonNull(item,"item cannot be null");
166     return _links == null ? false : _links.remove(value);
167   }
168 
169   public List<Diagram> getDiagrams() {
170     return _diagrams;
171   }
172 
173   public void setDiagrams(List<Diagram> value) {
174     _diagrams = value;
175   }
176 
177   /**
178    * Add a new {@link Diagram} item to the underlying collection.
179    * @param item the item to add
180    * @return {@code true}
181    */
182   public boolean addDiagram(Diagram item) {
183     Diagram value = ObjectUtils.requireNonNull(item,"item cannot be null");
184     if (_diagrams == null) {
185       _diagrams = new LinkedList<>();
186     }
187     return _diagrams.add(value);
188   }
189 
190   /**
191    * Remove the first matching {@link Diagram} item from the underlying collection.
192    * @param item the item to remove
193    * @return {@code true} if the item was removed or {@code false} otherwise
194    */
195   public boolean removeDiagram(Diagram item) {
196     Diagram value = ObjectUtils.requireNonNull(item,"item cannot be null");
197     return _diagrams == null ? false : _diagrams.remove(value);
198   }
199 
200   public MarkupMultiline getRemarks() {
201     return _remarks;
202   }
203 
204   public void setRemarks(MarkupMultiline value) {
205     _remarks = value;
206   }
207 
208   @Override
209   public String toString() {
210     return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString();
211   }
212 }