56bab318800f757bd4980309d154c9264fe88471
[so.git] / adapters / mso-adapter-utils / src / main / java / org / onap / so / 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  * Modifications Copyright (c) 2019 Samsung
9  * ================================================================================
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  * 
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  * 
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.so.openstack.utils;
25
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 public class MsoHeatEnvironmentResource {
30
31     private static final Logger logger = LoggerFactory.getLogger(MsoHeatEnvironmentResource.class);
32     
33         private String name;
34         private String value;
35         
36         public MsoHeatEnvironmentResource(String name, String value) {
37                 super();
38                 this.name = name;
39                 this.value = value;
40         }
41         public MsoHeatEnvironmentResource(String name) {
42                 // Allow to initialize with a null value
43                 this(name, null);
44         }
45         public MsoHeatEnvironmentResource() {
46                 this(null, null);
47         }
48         
49         public String getName() {
50                 return this.name;
51         }
52         public void setName(String name) {
53                 this.name = name;
54         }
55         
56         public String getValue() {
57                 return this.value;
58         }
59         public void setValue(String value) {
60                 this.value = value;
61         }
62
63         @Override
64         public String toString() {
65                 return "\"" +
66                         this.name +
67                         "\": " +
68                         this.value;
69         }
70
71         @Override
72         public boolean equals(Object o) {       
73                 if (!(o instanceof MsoHeatEnvironmentResource)) {
74                         return false;
75                 }
76                 if (this == o) {
77                         return true;
78                 }
79                 MsoHeatEnvironmentResource her = (MsoHeatEnvironmentResource) o;        
80                 // If the name of the parameter is the same, then they're equal
81                 if (her.getName().equals(this.getName())) {
82                         return true;
83                 }
84                 return false;
85         }
86
87         @Override
88         public int hashCode() {
89                 int result = 0;
90                 try {
91                         result = this.name.hashCode();
92                 } catch (Exception e) {
93         logger.debug("Exception:", e);
94     }
95                 return result;
96         }
97
98
99 }