Merge "Reorder modifiers"
[so.git] / mso-catalog-db / src / main / java / org / openecomp / mso / db / catalog / beans / ServiceMacroHolder.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.openecomp.mso.db.catalog.beans;
21
22 import java.io.Serializable;
23 import java.util.ArrayList;
24 import java.util.List;
25
26 /*
27  * A simple holder for Service and its associated elements:
28  * VnfResource, 1-n VfModule, Network TBD
29  */
30
31 public class ServiceMacroHolder implements Serializable {
32         
33         private static final long serialVersionUID = 768026109321305392L;
34
35         private Service service;
36         private List<VnfResource> vnfResources;
37         private List<NetworkResourceCustomization> networkResourceCustomization;
38         private List<AllottedResourceCustomization> allottedResourceCustomization;
39         private List<VnfResourceCustomization> vnfResourceCustomizations;
40
41         public ServiceMacroHolder() {
42                 super();
43                 this.service = null;
44                 this.vnfResources = new ArrayList<>();
45                 this.networkResourceCustomization = new ArrayList<>();
46                 this.allottedResourceCustomization = new ArrayList<>();
47                 this.vnfResourceCustomizations = new ArrayList<>();
48         }
49         public ServiceMacroHolder(Service service) {
50                 this();
51                 this.service = service;
52         }
53
54         public Service getService() {
55                 return this.service;
56         }
57         public void setService(Service service) {
58                 this.service = service;
59         }
60
61         public void setVnfResources(List<VnfResource> vnfResources) {
62                 this.vnfResources = vnfResources;
63         }
64         public List<VnfResource> getVnfResources() {
65                 return this.vnfResources;
66         }
67         public void addVnfResource(VnfResource vr) {
68                 if (vr != null) {
69                         if (this.vnfResources != null) {
70                                 this.vnfResources.add(vr);
71                         } else {
72                                 this.vnfResources = new ArrayList<>();
73                                 this.vnfResources.add(vr);
74                         }
75                 }
76         }
77
78         public void setVnfResourceCustomizations(List<VnfResourceCustomization> vnfResourceCustomizations) {
79                 this.vnfResourceCustomizations = vnfResourceCustomizations;
80         }
81         public List<VnfResourceCustomization> getVnfResourceCustomizations() {
82                 return this.vnfResourceCustomizations;
83         }
84         public void addVnfResourceCustomizations(VnfResourceCustomization vrc) {
85                 if (vrc != null) {
86                         if (this.vnfResourceCustomizations != null) {
87                                 this.vnfResourceCustomizations.add(vrc);
88                         } else {
89                                 this.vnfResourceCustomizations = new ArrayList<>();
90                                 this.vnfResourceCustomizations.add(vrc);
91                         }
92                 }
93         }
94         
95         public void setNetworkResourceCustomization(List<NetworkResourceCustomization> networkResourceCustomizations) {
96                 this.networkResourceCustomization = networkResourceCustomizations;
97         }
98         public List<NetworkResourceCustomization> getNetworkResourceCustomization() {
99                 return this.networkResourceCustomization;
100         }
101         public void addNetworkResourceCustomizations(NetworkResourceCustomization nrc) {
102                 if (this.networkResourceCustomization != null) {
103                         this.networkResourceCustomization.add(nrc);
104                 } else {
105                         this.networkResourceCustomization = new ArrayList<>();
106                         this.networkResourceCustomization.add(nrc);
107                 }
108         }
109
110         public void setAllottedResourceCustomization(List<AllottedResourceCustomization> allottedResourceCustomizations) {
111                 this.allottedResourceCustomization = allottedResourceCustomizations;
112         }
113         public List<AllottedResourceCustomization> getAllottedResourceCustomization() {
114                 return this.allottedResourceCustomization;
115         }
116         public void addAllottedResourceCustomization(AllottedResourceCustomization arc) {
117                 if (this.allottedResourceCustomization != null) {
118                         this.allottedResourceCustomization.add(arc);
119                 } else {
120                         this.allottedResourceCustomization = new ArrayList<>();
121                         this.allottedResourceCustomization.add(arc);
122                 }
123         }
124
125     @Override
126         public String toString() {
127                 StringBuilder sb = new StringBuilder();
128                 sb.append("ServicePlus: ");
129                 if (this.service != null) {
130                         sb.append("service: ").append(this.service.toString());
131                 } else {
132                         sb.append("service: null");
133                 }
134                 if (this.vnfResourceCustomizations != null && this.vnfResourceCustomizations.size() > 0) {
135                         int i=0;
136                         sb.append("vnfResourceCustomization: ");
137                         for (VnfResourceCustomization vrc : this.vnfResourceCustomizations) {
138                                 sb.append(", vnfResourceCustomization[").append(i++).append("]:").append(vrc.toString());
139                         }
140                 } else {
141                         sb.append("none");
142                 }
143                 if (this.vnfResources != null && this.vnfResources.size() > 0) {
144                         int i=0;
145                         sb.append("VnfResources: ");
146                         for (VnfResource vr : this.vnfResources) {
147                                 sb.append(", vnfResource[").append(i++).append("]:").append(vr.toString());
148                         }
149                 } else {
150                         sb.append("none");
151                 }
152                 if (this.networkResourceCustomization != null && this.networkResourceCustomization.size() > 0) {
153                         int i=0;
154                         sb.append("NetworkResourceCustomizations:");
155                         for (NetworkResourceCustomization nrc : this.networkResourceCustomization) {
156                                 sb.append("NRC[").append(i++).append("]: ").append(nrc.toString());
157                         }
158                 }
159                 if (this.allottedResourceCustomization != null && this.allottedResourceCustomization.size() > 0) {
160                         int i=0;
161                         sb.append("AllottedResourceCustomizations:");
162                         for (AllottedResourceCustomization arc : this.allottedResourceCustomization) {
163                                 sb.append("ARC[").append(i++).append("]: ").append(arc.toString());
164                         }
165                 }
166
167                 return sb.toString();
168         }
169
170
171 }