Replace StringBuilder with String & inline return
[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                 return "\"" +
63                         this.name +
64                         "\": " +
65                         this.value;
66         }
67
68         @Override
69         public boolean equals(Object o) {       
70                 if (!(o instanceof MsoHeatEnvironmentResource)) {
71                         return false;
72                 }
73                 if (this == o) {
74                         return true;
75                 }
76                 MsoHeatEnvironmentResource her = (MsoHeatEnvironmentResource) o;        
77                 // If the name of the parameter is the same, then they're equal
78                 if (her.getName().equals(this.getName())) {
79                         return true;
80                 }
81                 return false;
82         }
83
84         @Override
85         public int hashCode() {
86                 int result = 0;
87                 try {
88                         result = this.name.hashCode();
89                 } catch (Exception e) {
90                     LOGGER.debug("Exception:", e);
91                 }
92                 return result;
93         }
94
95
96 }