483c6fcabccbd397583b73bc302c67ab78984f0b
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / components / ServiceMetadataDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
21 package org.openecomp.sdc.be.datatypes.components;
22
23 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor;
24
25
26
27 public class ServiceMetadataDataDefinition extends ComponentMetadataDataDefinition {
28     private static final String EMPTY_STR = "";
29
30     private String distributionStatus;
31     private String serviceType;
32     private String serviceRole;
33     private String instantiationType = EMPTY_STR;
34         private String serviceFunction;
35
36     private Boolean ecompGeneratedNaming = true;
37
38     private String namingPolicy = EMPTY_STR;
39
40     private String environmentContext;
41
42     public ServiceMetadataDataDefinition() {
43         super();
44         serviceType = "";
45         serviceRole = "";
46                 serviceFunction = "";
47     }
48
49
50     public ServiceMetadataDataDefinition(ServiceMetadataDataDefinition other) {
51         super(other);
52         serviceType = other.getServiceType();
53         serviceRole = other.getServiceRole();
54                 serviceFunction = other.getServiceFunction();
55         }
56
57         public ServiceMetadataDataDefinition(JsonPresentationFieldsExtractor extractor){
58                 super(extractor);
59                 serviceType = extractor.getServiceType();
60                 serviceRole = extractor.getServiceRole();
61                 serviceFunction = extractor.getServiceFunction();
62     }
63
64     public String getDistributionStatus() {
65         return distributionStatus;
66     }
67
68     public void setDistributionStatus(String distributionStatus) {
69         this.distributionStatus = distributionStatus;
70     }
71
72     public String getServiceType() {
73         return serviceType;
74     }
75
76     public void setServiceType(String serviceType) {
77         this.serviceType = serviceType;
78     }
79
80     public String getServiceRole() {
81         return serviceRole;
82     }
83
84     public String getInstantiationType() {
85         return instantiationType;
86     }
87
88     public void setInstantiationType(String instantiationType) {
89         this.instantiationType = instantiationType;
90     }
91
92     public void setServiceRole(String serviceRole) {
93         this.serviceRole = serviceRole;
94     }
95
96     public Boolean isEcompGeneratedNaming() {
97         return ecompGeneratedNaming;
98     }
99
100         public Boolean getEcompGeneratedNaming() {
101                 return ecompGeneratedNaming;
102         }
103
104     public void setEcompGeneratedNaming(Boolean ecompGeneratedNaming) {
105         this.ecompGeneratedNaming = ecompGeneratedNaming;
106     }
107
108     public String getNamingPolicy() {
109         return namingPolicy;
110     }
111
112     public void setNamingPolicy(String namingPolicy) {
113         this.namingPolicy = namingPolicy;
114     }
115
116     public String getEnvironmentContext() {
117         return environmentContext;
118     }
119
120     public void setEnvironmentContext(String environmentContext) {
121         this.environmentContext = environmentContext;
122     }
123
124         public String getServiceFunction() {
125                 return serviceFunction;
126         }
127
128         public void setServiceFunction(String serviceFunction) {
129                 this.serviceFunction = serviceFunction;
130         }
131
132         @Override
133         public String toString() {
134                 return "ServiceMetadataDataDefinition{" +
135                                 "distributionStatus='" + distributionStatus + '\'' +
136                                 ", serviceType='" + serviceType + '\'' +
137                                 ", serviceRole='" + serviceRole + '\'' +
138                                 ", serviceFunction='" + serviceFunction + '\'' +
139                                 ", ecompGeneratedNaming=" + ecompGeneratedNaming +
140                                 ", namingPolicy='" + namingPolicy + '\'' +
141                                 ", environmentContext='" + environmentContext + '\'' +
142                                 ", instantiationType='" + instantiationType + '\'' +
143                                 '}';
144         }
145
146     @Override
147     public int hashCode() {
148         final int prime = 31;
149         int result = super.hashCode();
150         result = prime * result + ((distributionStatus == null) ? 0 : distributionStatus.hashCode());
151         result = prime * result + ((ecompGeneratedNaming == null) ? 0 : ecompGeneratedNaming.hashCode());
152         result = prime * result + ((namingPolicy == null) ? 0 : namingPolicy.hashCode());
153         result = prime * result + ((serviceType == null) ? 0 : serviceType.hashCode());
154         result = prime * result + ((serviceRole == null) ? 0 : serviceRole.hashCode());
155                 result = prime * result + ((serviceFunction == null) ? 0 : serviceFunction.hashCode());
156         result = prime * result + ((environmentContext == null) ? 0 : environmentContext.hashCode());
157         result = prime * result + ((instantiationType == null) ? 0 : instantiationType.hashCode());
158         return result;
159     }
160
161     @Override
162     public boolean equals(Object obj) {
163         if (this == obj) {
164             return true;
165         }
166         if (obj == null) {
167             return false;
168         }
169         if (!(obj instanceof ComponentMetadataDataDefinition)) {
170             return false;
171         }
172         if (!super.equals(obj)) {
173             return false;
174         }
175         if (getClass() != obj.getClass()) {
176             return false;
177         }
178         ServiceMetadataDataDefinition other = (ServiceMetadataDataDefinition) obj;
179         if (distributionStatus == null) {
180             if (other.distributionStatus != null) {
181                 return false;
182             }
183         } else if (!distributionStatus.equals(other.distributionStatus)) {
184             return false;
185         }
186         if (ecompGeneratedNaming == null) {
187             if (other.ecompGeneratedNaming != null) {
188                 return false;
189             }
190         } else if (!ecompGeneratedNaming.equals(other.ecompGeneratedNaming)) {
191             return false;
192         }
193         if (namingPolicy == null) {
194             if (other.namingPolicy != null) {
195                 return false;
196             }
197         } else if (!namingPolicy.equals(other.namingPolicy)) {
198             return false;
199         }
200         if (serviceType == null) {
201             if (other.serviceType != null) {
202                 return false;
203             }
204         } else if (!serviceType.equals(other.serviceType)) {
205             return false;
206         }
207         if (serviceRole == null) {
208             if (other.serviceRole != null) {
209                 return false;
210             }
211         } else if (!serviceRole.equals(other.serviceRole)) {
212             return false;
213         }
214         if (environmentContext == null) {
215             if (other.environmentContext != null) {
216                 return false;
217             }
218         } else if (!environmentContext.equals(other.environmentContext)) {
219             return false;
220         }
221         if (instantiationType == null) {
222             if (other.instantiationType != null) {
223                 return false;
224             }
225         } else if (!instantiationType.equals(other.instantiationType)) {
226             return false;
227         }
228         if (serviceFunction == null){
229             if (other.serviceFunction != null) {
230                 return false;
231         } else if (!serviceFunction.equals(other.serviceFunction))
232             return false;
233         }
234         return super.equals(obj);
235     }
236
237     @Override
238     public String getActualComponentType() {
239
240         return componentType != null ? componentType.getValue() : "";
241     }
242
243 }