2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.openecomp.appc.dg.objects;
26 import org.openecomp.appc.domainmodel.Vnfc;
29 public class VnfcFlowModel {
30 private Map<Integer,List<Vnfc>> flowModelMap;
32 private VnfcFlowModel(VnfcFlowModelBuilder builder){
33 this.flowModelMap = builder.map;
38 public String toString() {
39 StringBuilder stringBuilder = new StringBuilder("Flow Model : ");
40 Iterator<List<Vnfc>> iterator = getModelIterator();
41 while(iterator.hasNext()){
42 for(Vnfc vnfc:iterator.next()){
43 stringBuilder.append(vnfc.toString()).append(", \n");
47 return stringBuilder.toString();
50 public Iterator<List<Vnfc>> getModelIterator(){
51 return flowModelMap.values().iterator();
54 public static class VnfcFlowModelBuilder{
56 Map<Integer,List<Vnfc>> map;
58 public VnfcFlowModelBuilder(){
59 map = new HashMap<>();
62 public VnfcFlowModelBuilder addMetadata(Integer index,Vnfc vnfc){
63 List<Vnfc> vnfcList = this.map.get(index);
65 vnfcList = new LinkedList<>();
66 map.put(index,vnfcList);
72 public VnfcFlowModelBuilder addMetadata(Integer index,List<Vnfc> vnfcs){
73 List<Vnfc> vnfcList = this.map.get(index);
75 vnfcList = new LinkedList<>();
76 map.put(index,vnfcList);
78 vnfcList.addAll(vnfcs);
82 public VnfcFlowModel build(){
83 return new VnfcFlowModel(this);