2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Amdocs
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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.openecomp.appc.dg.objects;
27 import org.openecomp.appc.domainmodel.Vnfc;
30 public class VnfcFlowModel {
31 private Map<Integer,List<Vnfc>> flowModelMap;
33 private VnfcFlowModel(VnfcFlowModelBuilder builder){
34 this.flowModelMap = builder.map;
39 public String toString() {
40 StringBuilder stringBuilder = new StringBuilder("Flow Model : ");
41 Iterator<List<Vnfc>> iterator = getModelIterator();
42 while(iterator.hasNext()){
43 for(Vnfc vnfc:iterator.next()){
44 stringBuilder.append(vnfc.toString()).append(", \n");
48 return stringBuilder.toString();
51 public Iterator<List<Vnfc>> getModelIterator(){
52 return flowModelMap.values().iterator();
55 public static class VnfcFlowModelBuilder{
57 Map<Integer,List<Vnfc>> map;
59 public VnfcFlowModelBuilder(){
60 map = new HashMap<>();
63 public VnfcFlowModelBuilder addMetadata(Integer index,Vnfc vnfc){
64 List<Vnfc> vnfcList = this.map.get(index);
66 vnfcList = new LinkedList<>();
67 map.put(index,vnfcList);
73 public VnfcFlowModelBuilder addMetadata(Integer index,List<Vnfc> vnfcs){
74 List<Vnfc> vnfcList = this.map.get(index);
76 vnfcList = new LinkedList<>();
77 map.put(index,vnfcList);
79 vnfcList.addAll(vnfcs);
83 public VnfcFlowModel build(){
84 return new VnfcFlowModel(this);