AT&T 1712 and 1802 release code
[so.git] / adapters / mso-adapter-utils / src / main / java / org / openecomp / mso / cloud / CloudSite.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.mso.cloud;
22
23
24 import com.fasterxml.jackson.annotation.JsonProperty;
25
26 /**
27  * JavaBean JSON class for a CloudSite.  This bean represents a cloud location
28  * (i.e. and LCP node) in the NVP/AIC cloud.  It will be loaded via CloudConfig
29  * object, of which it is a component (a CloudConfig JSON configuration file
30  * will contain multiple CloudSite definitions).
31  *
32  * Note that this is only used to access Cloud Configurations loaded from a
33  * JSON config file, so there are no explicit setters.
34  *
35  */
36 public class CloudSite {
37         @JsonProperty
38         private String id;
39         @JsonProperty("region_id")
40         private String regionId;
41         @JsonProperty("identity_service_id")
42         private String identityServiceId;
43         @JsonProperty("aic_version")
44         private String aic_version;
45         @JsonProperty("clli")
46         private String clli;
47         @JsonProperty("cloudify_id")
48         private String cloudifyId;
49         @JsonProperty("platform")
50         private String platform;
51         @JsonProperty("orchestrator")
52         private String orchestrator;
53
54         // Derived property (set by CloudConfig loader based on identityServiceId)
55         private CloudIdentity identityService;
56         // Derived property (set by CloudConfig loader based on cloudifyId)
57         private CloudifyManager cloudifyManager;
58
59         public CloudSite() {}
60         
61         public String getId() {
62                 return id;
63         }
64         public void setId(String id) {
65                 this.id = id;
66         }
67         
68         public String getRegionId() {
69                 return regionId;
70         }
71         
72         public void setRegionId(String regionId) {
73                 this.regionId = regionId;
74         }
75
76         public String getIdentityServiceId() {
77                 return identityServiceId;
78         }
79
80         public CloudIdentity getIdentityService () {
81                 return identityService;
82         }
83
84         public void setIdentityService (CloudIdentity identity) {
85                 this.identityService = identity;
86         }
87         
88         public String getAic_version() {
89                 return aic_version;
90         }
91
92         public void setAic_version(String aic_version) {
93                 this.aic_version = aic_version;
94         }
95
96         public String getClli() {
97                 return clli;
98         }
99
100         public void setClli(String clli) {
101                 this.clli = clli;
102         }
103
104         public String getCloudifyId() {
105                 return cloudifyId;
106         }
107
108         public void setCloudifyId (String id) {
109                 this.cloudifyId = id;
110         }
111
112         public CloudifyManager getCloudifyManager () {
113                 return cloudifyManager;
114         }
115
116         public void setCloudifyManager (CloudifyManager cloudify) {
117                 this.cloudifyManager = cloudify;
118         }
119         
120         public String getPlatform() {
121                 return platform;
122         }
123
124         public void setPlatform(String platform) {
125                 this.platform = platform;
126         }
127
128         public String getOrchestrator() {
129                 return orchestrator;
130         }
131
132         public void setOrchestrator(String orchestrator) {
133                 this.orchestrator = orchestrator;
134         }
135
136         @Override
137         public String toString() {
138                 return "CloudSite: id=" + id +
139                         ", regionId=" + regionId +
140                         ", identityServiceId=" + identityServiceId +
141                         ", aic_version=" + aic_version +
142                         ", clli=" + clli +
143                         ", cloudifyId=" + cloudifyId +
144                         ", platform=" + platform +
145                         ", orchestrator=" + orchestrator;
146         }
147
148         @Override
149         public CloudSite clone() {
150                 CloudSite cloudSiteCopy = new CloudSite();
151                 cloudSiteCopy.id = this.id;
152                 cloudSiteCopy.regionId = this.regionId;
153                 cloudSiteCopy.identityServiceId = this.identityServiceId;
154                 cloudSiteCopy.aic_version = this.aic_version;
155                 cloudSiteCopy.clli = this.clli;
156                 cloudSiteCopy.identityService = this.identityService.clone();
157                 cloudSiteCopy.cloudifyId = this.cloudifyId;
158                 if (this.cloudifyManager != null)  cloudSiteCopy.cloudifyManager = this.cloudifyManager.clone();
159                 cloudSiteCopy.platform = this.platform;
160                 cloudSiteCopy.orchestrator = this.orchestrator;
161
162                 return cloudSiteCopy;
163         }
164
165         @Override
166         public int hashCode() {
167                 final int prime = 31;
168                 int result = 1;
169                 result = prime * result + ((id == null) ? 0 : id.hashCode());
170                 result = prime * result + ((identityService == null) ? 0 : identityService.hashCode());
171                 result = prime * result + ((identityServiceId == null) ? 0 : identityServiceId.hashCode());
172                 result = prime * result + ((regionId == null) ? 0 : regionId.hashCode());
173                 result = prime * result + ((aic_version == null) ? 0 : aic_version.hashCode());
174                 result = prime * result + ((clli == null) ? 0 : clli.hashCode());
175                 return result;
176         }
177
178         @Override
179         public boolean equals(Object obj) {
180                 if (this == obj)
181                         return true;
182                 if (obj == null)
183                         return false;
184                 if (getClass() != obj.getClass())
185                         return false;
186                 CloudSite other = (CloudSite) obj;
187                 if (!cmp(id, other.id))
188                         return false;
189                 if (!cmp(regionId, other.regionId))
190                         return false;
191                 if (!cmp(identityServiceId, other.identityServiceId))
192                         return false;
193                 if (!cmp(aic_version, other.aic_version))
194                         return false;
195                 if (!cmp(clli, other.clli))
196                         return false;
197                 if (!cmp(identityService, other.identityService))
198                         return false;
199                 return true;
200         }
201         private boolean cmp(Object a, Object b) {
202                 if (a == null) {
203                         return (b == null);
204                 } else {
205                         return a.equals(b);
206                 }
207         }
208 }