First part of onap rename
[appc.git] / appc-dg / appc-dg-shared / appc-dg-domain-model-lib / src / main / java / org / openecomp / appc / domainmodel / Vnfc.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.domainmodel;
26
27 import java.util.LinkedList;
28 import java.util.List;
29
30
31 public class Vnfc {
32
33     private String vnfcType;
34
35     public void setResilienceType(String resilienceType) {
36         this.resilienceType = resilienceType;
37     }
38
39     private String resilienceType;
40     private boolean mandatory;
41     private String vnfcName;
42     private List<Vserver> vserverList;
43
44     public Vnfc(String vnfcType,String resilienceType){
45         this(vnfcType,resilienceType,null, false);
46     }
47
48     public Vnfc(String vnfcType,String resilienceType,String vnfcName){
49         this(vnfcType,resilienceType,vnfcName, false);
50     }
51
52     public Vnfc(String vnfcType,String resilienceType,String vnfcName, boolean mandatory){
53         this.vnfcName = vnfcName;
54         this.vnfcType = vnfcType;
55         this.resilienceType = resilienceType;
56         this.mandatory = mandatory;
57         this.vserverList = new LinkedList<>();
58     }
59
60     @Override
61     public String toString() {
62         StringBuilder stringBuilder = new StringBuilder("Vnfc : vnfcType = " + vnfcType + ", vnfcName = " +vnfcName + ", resilienceType = " + resilienceType+", mandatory = " + mandatory);
63         for(Vserver vserver:vserverList){
64             stringBuilder.append(vserver.toString()).append(", \n");
65         }
66         return stringBuilder.toString();
67     }
68
69     @Override
70     public int hashCode(){
71         final int prime = 31;
72         int result = 1;
73         result = result * prime + (this.vnfcType == null ? 0 :this.vnfcType.hashCode());
74         result = result * prime + (this.resilienceType == null ? 0 :this.resilienceType.hashCode());
75         result = result * prime + (this.vnfcName == null ? 0 :this.vnfcName.hashCode());
76         result = result * prime + (Boolean.valueOf(this.mandatory).hashCode());
77         return result;
78     }
79     @Override
80     public boolean equals(Object object){
81         if(object == null){
82             return false;
83         }
84         if(!(object instanceof Vnfc)){
85             return false;
86         }
87         Vnfc vnfc = (Vnfc)object;
88
89         if(this.vnfcType == null){
90             if(vnfc.vnfcType !=null)
91                 return false;
92         }
93         else if(!this.vnfcType.equals(vnfc.vnfcType))
94             return false;
95
96         if(this.resilienceType == null){
97             if(vnfc.resilienceType !=null)
98                 return false;
99         }
100         else if(!this.resilienceType.equals(vnfc.resilienceType))
101             return false;
102
103         if(this.vnfcName == null){
104             if(vnfc.vnfcName !=null)
105                 return false;
106         }
107         else if(!this.vnfcName.equals(vnfc.vnfcName))
108             return false;
109         if (this.mandatory != vnfc.mandatory)
110             return false;
111         return true;
112     }
113
114     public void addVm(Vserver vserver){
115         this.vserverList.add(vserver);
116     }
117     public void addVms(List<Vserver> vserverList){
118         this.vserverList.addAll(vserverList);
119     }
120
121     public void setVnfcName(String vnfcName) {
122         this.vnfcName = vnfcName;
123     }
124
125     public String getVnfcType() {
126         return vnfcType;
127     }
128
129     public String getResilienceType() {
130         return resilienceType;
131     }
132
133     public String getVnfcName() {
134         return vnfcName;
135     }
136
137     public List<Vserver> getVserverList() {
138         return vserverList;
139     }
140
141     public boolean isMandatory() {
142         return mandatory;
143     }
144
145     public void setMandatory(boolean mandatory) {
146         this.mandatory = mandatory;
147     }
148 }