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