Merge "Added the "@Override" annotation"
[so.git] / adapters / mso-adapter-utils / src / main / java / org / openecomp / mso / openstack / utils / MsoHeatEnvironmentResource.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
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  */
21
22 package org.openecomp.mso.openstack.utils;
23
24 import org.openecomp.mso.logger.MsoLogger;
25
26 public class MsoHeatEnvironmentResource {
27
28     private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
29     
30         private String name;
31         private String value;
32         
33         public MsoHeatEnvironmentResource(String name, String value) {
34                 super();
35                 this.name = name;
36                 this.value = value;
37         }
38         public MsoHeatEnvironmentResource(String name) {
39                 // Allow to initialize with a null value
40                 this(name, null);
41         }
42         public MsoHeatEnvironmentResource() {
43                 this(null, null);
44         }
45         
46         public String getName() {
47                 return this.name;
48         }
49         public void setName(String name) {
50                 this.name = name;
51         }
52         
53         public String getValue() {
54                 return this.value;
55         }
56         public void setValue(String value) {
57                 this.value = value;
58         }
59
60         @Override
61         public String toString() {
62                 StringBuilder str = new StringBuilder();
63                 str.append("\"");
64                 str.append(this.name);
65                 str.append("\": ");
66                 str.append(this.value);
67                 return str.toString();
68         }
69
70         @Override
71         public boolean equals(Object o) {       
72                 if (!(o instanceof MsoHeatEnvironmentResource)) {
73                         return false;
74                 }
75                 if (this == o) {
76                         return true;
77                 }
78                 MsoHeatEnvironmentResource her = (MsoHeatEnvironmentResource) o;        
79                 // If the name of the parameter is the same, then they're equal
80                 if (her.getName().equals(this.getName())) {
81                         return true;
82                 }
83                 return false;
84         }
85
86         @Override
87         public int hashCode() {
88                 int result = 0;
89                 try {
90                         result = this.name.hashCode();
91                 } catch (Exception e) {
92                     LOGGER.debug("Exception:", e);
93                 }
94                 return result;
95         }
96
97
98 }