2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.sdc.toscaparser.api;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.stream.Collectors;
27 public class RequirementAssignments {
29 private List<RequirementAssignment> requirementAssignmentList;
31 public RequirementAssignments(List<RequirementAssignment> requirementAssignments) {
32 this.requirementAssignmentList = requirementAssignments != null ? new ArrayList<>(requirementAssignments) : new ArrayList<>();
36 * Get all requirement assignments for Node Template.<br>
37 * This object can be either the original one, holding all requirement assignments for this node template,or a filtered one, holding a filtered subset.<br>
39 * @return list of requirement assignments for the node template. <br>
40 * If there are no requirement assignments, empty list is returned.
42 public List<RequirementAssignment> getAll() {
43 return new ArrayList<>(requirementAssignmentList);
47 * Filter requirement assignments by requirement name.
49 * @param reqName - The name of requirement
50 * @return RequirementAssignments object, containing requirement assignments of this type.<br>
51 * If no such found, filtering will result in an empty collection.
53 public RequirementAssignments getRequirementsByName(String reqName) {
54 List<RequirementAssignment> requirementAssignments = requirementAssignmentList.stream()
55 .filter(req -> req.getName().equals(reqName)).collect(Collectors.toList());
57 return new RequirementAssignments(requirementAssignments);