Change the header to SO
[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 org.codehaus.jackson.annotate.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
48         // Derived property (set by CloudConfig loader based on identityServiceId)
49         private CloudIdentity identityService;
50
51         public CloudSite() {}
52         
53         public String getId() {
54                 return id;
55         }
56         public void setId(String id) {
57                 this.id = id;
58         }
59         
60         public String getRegionId() {
61                 return regionId;
62         }
63         
64         public void setRegionId(String regionId) {
65                 this.regionId = regionId;
66         }
67
68         public String getIdentityServiceId() {
69                 return identityServiceId;
70         }
71
72         public CloudIdentity getIdentityService () {
73                 return identityService;
74         }
75
76         public void setIdentityService (CloudIdentity identity) {
77                 this.identityService = identity;
78         }
79         
80         public String getAic_version() {
81                 return aic_version;
82         }
83
84         public void setAic_version(String aic_version) {
85                 this.aic_version = aic_version;
86         }
87
88         public String getClli() {
89                 return clli;
90         }
91
92         public void setClli(String clli) {
93                 this.clli = clli;
94         }
95
96         @Override
97         public String toString() {
98                 return "CloudSite: id=" + id +
99                         ", regionId=" + regionId +
100                         ", identityServiceId=" + identityServiceId +
101                         ", aic_version=" + aic_version +
102                         ", clli=" + clli;
103         }
104
105         @Override
106         public CloudSite clone() {
107                 CloudSite cloudSiteCopy = new CloudSite();
108                 cloudSiteCopy.id = this.id;
109                 cloudSiteCopy.regionId = this.regionId;
110                 cloudSiteCopy.identityServiceId = this.identityServiceId;
111                 cloudSiteCopy.aic_version = this.aic_version;
112                 cloudSiteCopy.clli = this.clli;
113                 cloudSiteCopy.identityService = this.identityService.clone();
114                 return cloudSiteCopy;
115         }
116
117         @Override
118         public int hashCode() {
119                 final int prime = 31;
120                 int result = 1;
121                 result = prime * result + ((id == null) ? 0 : id.hashCode());
122                 result = prime * result + ((identityService == null) ? 0 : identityService.hashCode());
123                 result = prime * result + ((identityServiceId == null) ? 0 : identityServiceId.hashCode());
124                 result = prime * result + ((regionId == null) ? 0 : regionId.hashCode());
125                 result = prime * result + ((aic_version == null) ? 0 : aic_version.hashCode());
126                 result = prime * result + ((clli == null) ? 0 : clli.hashCode());
127                 return result;
128         }
129
130         @Override
131         public boolean equals(Object obj) {
132                 if (this == obj)
133                         return true;
134                 if (obj == null)
135                         return false;
136                 if (getClass() != obj.getClass())
137                         return false;
138                 CloudSite other = (CloudSite) obj;
139                 if (!cmp(id, other.id))
140                         return false;
141                 if (!cmp(regionId, other.regionId))
142                         return false;
143                 if (!cmp(identityServiceId, other.identityServiceId))
144                         return false;
145                 if (!cmp(aic_version, other.aic_version))
146                         return false;
147                 if (!cmp(clli, other.clli))
148                         return false;
149                 if (!cmp(identityService, other.identityService))
150                         return false;
151                 return true;
152         }
153         private boolean cmp(Object a, Object b) {
154                 if (a == null) {
155                         return (b == null);
156                 } else {
157                         return a.equals(b);
158                 }
159         }
160 }