f908286bd742b18dc8c2f5d321986746aa0586d9
[appc.git] / appc-dg / appc-dg-shared / appc-dg-domain-model-lib / src / main / java / org / onap / appc / domainmodel / Vnfc.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.domainmodel;
25
26 import java.util.LinkedList;
27 import java.util.List;
28
29
30 public class Vnfc {
31
32     private String vnfcType;
33     private String resilienceType;
34     private boolean mandatory;
35     private String vnfcName;
36     private List<Vserver> vserverList;
37
38     public Vnfc(){
39         this.vserverList = new LinkedList<>();
40     }
41
42     @Override
43     public String toString() {
44         StringBuilder stringBuilder = new StringBuilder().append("Vnfc : vnfcType = ").append(vnfcType).append(", vnfcName = ").append(vnfcName).append(", resilienceType = " ).append(resilienceType).append(", mandatory = ").append(mandatory);
45         for(Vserver vserver:vserverList){
46             stringBuilder.append(vserver.toString()).append(", \n");
47         }
48         return stringBuilder.toString();
49     }
50
51     @Override
52     public int hashCode(){
53         final int prime = 31;
54         int result = 1;
55         result = result * prime + (this.vnfcType == null ? 0 :this.vnfcType.hashCode());
56         result = result * prime + (this.resilienceType == null ? 0 :this.resilienceType.hashCode());
57         result = result * prime + (this.vnfcName == null ? 0 :this.vnfcName.hashCode());
58         result = result * prime + (Boolean.valueOf(this.mandatory).hashCode());
59         return result;
60     }
61     @Override
62     public boolean equals(Object object){
63         if(object == null){
64             return false;
65         }
66         if(!(object instanceof Vnfc)){
67             return false;
68         }
69         Vnfc vnfc = (Vnfc)object;
70
71         if(this.vnfcType == null){
72             if(vnfc.vnfcType !=null)
73                 return false;
74         }
75         else if(!this.vnfcType.equals(vnfc.vnfcType))
76             return false;
77
78         if(this.resilienceType == null){
79             if(vnfc.resilienceType !=null)
80                 return false;
81         }
82         else if(!this.resilienceType.equals(vnfc.resilienceType))
83             return false;
84
85         if(this.vnfcName == null){
86             if(vnfc.vnfcName !=null)
87                 return false;
88         }
89         else if(!this.vnfcName.equals(vnfc.vnfcName))
90             return false;
91         if (this.mandatory != vnfc.mandatory)
92             return false;
93         return true;
94     }
95
96     public String getVnfcType() {
97         return vnfcType;
98     }
99
100     public void setVnfcType(String vnfcType) {
101         this.vnfcType = vnfcType;
102     }
103
104     public String getResilienceType() {
105         return resilienceType;
106     }
107
108     public void setResilienceType(String resilienceType) {
109         this.resilienceType = resilienceType;
110     }
111
112     public boolean isMandatory() {
113         return mandatory;
114     }
115
116     public void setMandatory(boolean mandatory) {
117         this.mandatory = mandatory;
118     }
119
120     public String getVnfcName() {
121         return vnfcName;
122     }
123
124     public void setVnfcName(String vnfcName) {
125         this.vnfcName = vnfcName;
126     }
127
128     public List<Vserver> getVserverList() {
129         return vserverList;
130     }
131
132     public void setVserverList(List<Vserver> vserverList) {
133         this.vserverList = vserverList;
134     }
135
136     public void addVservers(List<Vserver> vserverList){
137         this.vserverList.addAll(vserverList);
138     }
139
140     public void addVserver(Vserver vm) {
141         this.vserverList.add(vm);
142     }
143
144
145 }