694b476ce354aca048b52f786c332d94b7efe40e
[so.git] / so-etsi-nfvo / so-etsi-nfvo-ns-lcm / so-etsi-nfvo-ns-lcm-bpmn-flows / src / main / java / org / onap / so / etsi / nfvo / ns / lcm / bpmn / flows / nsd / NetworkServiceDescriptor.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.nsd;
21
22 import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Objects;
29
30 /**
31  * @author Waqas Ikram (waqas.ikram@est.tech)
32  *
33  */
34 public class NetworkServiceDescriptor implements Serializable {
35
36     private static final long serialVersionUID = -1739293595041180242L;
37
38     private String type;
39
40     private Map<String, Object> properties = new HashMap<>();
41
42     private List<VirtualNetworkFunction> vnfs = new ArrayList<>();
43
44     public String getType() {
45         return type;
46     }
47
48     public void setType(final String type) {
49         this.type = type;
50     }
51
52     public NetworkServiceDescriptor type(final String type) {
53         this.type = type;
54         return this;
55     }
56
57     public Map<String, Object> getProperties() {
58         return properties;
59     }
60
61     public void setProperties(final Map<String, Object> properties) {
62         this.properties = properties;
63     }
64
65     public NetworkServiceDescriptor properties(final Map<String, Object> properties) {
66         this.properties = properties;
67         return this;
68     }
69
70     public List<VirtualNetworkFunction> getVnfs() {
71         return vnfs;
72     }
73
74     public void setVnfs(final List<VirtualNetworkFunction> vnfs) {
75         if (vnfs != null) {
76             this.vnfs = vnfs;
77         } else {
78             this.vnfs = new ArrayList<>();
79         }
80     }
81
82     public NetworkServiceDescriptor addVnfPkgIdsItem(final VirtualNetworkFunction vnf) {
83         if (this.vnfs == null) {
84             this.vnfs = new ArrayList<>();
85         }
86         this.vnfs.add(vnf);
87         return this;
88     }
89
90     public NetworkServiceDescriptor vnfs(final List<VirtualNetworkFunction> vnfs) {
91         this.vnfs = vnfs;
92         return this;
93     }
94
95     @Override
96     public int hashCode() {
97         return Objects.hash(type, properties, vnfs);
98     }
99
100     @Override
101     public boolean equals(final Object obj) {
102         if (obj instanceof NetworkServiceDescriptor) {
103             final NetworkServiceDescriptor other = (NetworkServiceDescriptor) obj;
104             return Objects.equals(type, other.type) && Objects.equals(properties, other.properties)
105                     && Objects.equals(vnfs, other.vnfs);
106         }
107         return false;
108     }
109
110     @Override
111     public String toString() {
112         final StringBuilder sb = new StringBuilder();
113         sb.append("class NetworkServiceDescriptor {\n");
114         sb.append("    type: ").append(toIndentedString(type)).append("\n");
115         sb.append("    properties: ").append(toIndentedString(properties)).append("\n");
116         sb.append("    vnfs: ").append(toIndentedString(vnfs)).append("\n");
117         sb.append("}");
118         return sb.toString();
119     }
120
121 }