[SDC-31] add mising script got Comformance fix
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / AttributeDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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.sdc.be.datatypes.elements;
22
23 import java.io.Serializable;
24 import java.util.Objects;
25
26 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
27 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
28
29 /**
30  * Represents AttributeDataDefinition
31  * 
32  * @author mshitrit
33  *
34  */
35 public class AttributeDataDefinition extends ToscaDataDefinition implements Serializable {
36
37         /**
38          * 
39          */
40         private static final long serialVersionUID = -3046831950009259569L;
41
42         private String uniqueId;
43         private String name;
44         private String type;
45         private String description;
46
47         private String defaultValue;
48         private String value;
49
50         private String status;
51         private SchemaDefinition schema;
52
53         public AttributeDataDefinition() {
54                 // Used From Attribute Defenition
55         }
56
57         /**
58          * Clone Constructor
59          * 
60          * @param attribute
61          */
62         public AttributeDataDefinition(AttributeDataDefinition attribute) {
63                 this.uniqueId = attribute.uniqueId;
64                 this.name = attribute.name;
65                 this.type = attribute.type;
66                 this.description = attribute.description;
67                 this.defaultValue = attribute.defaultValue;
68                 this.value = attribute.value;
69                 this.status = attribute.status;
70                 this.schema = attribute.schema;
71         }
72
73         public String getUniqueId() {
74                 return uniqueId;
75         }
76
77         public void setUniqueId(String uniqueId) {
78                 this.uniqueId = uniqueId;
79         }
80
81         public String getName() {
82                 return name;
83         }
84
85         public void setName(String name) {
86                 this.name = name;
87         }
88
89         public String getType() {
90                 return type;
91         }
92
93         public void setType(String type) {
94                 this.type = type;
95         }
96
97         public String getDescription() {
98                 return description;
99         }
100
101         public void setDescription(String description) {
102                 this.description = description;
103         }
104
105         public String getDefaultValue() {
106                 return defaultValue;
107         }
108
109         public void setDefaultValue(String defaultValue) {
110                 this.defaultValue = defaultValue;
111         }
112
113         public String getStatus() {
114                 return status;
115         }
116
117         public void setStatus(String status) {
118                 this.status = status;
119         }
120
121         public SchemaDefinition getSchema() {
122                 return schema;
123         }
124
125         public void setSchema(SchemaDefinition entrySchema) {
126                 this.schema = entrySchema;
127         }
128
129         @Override
130         public int hashCode() {
131                 final int prime = 31;
132                 int result = 1;
133                 result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
134                 result = prime * result + ((value == null) ? 0 : value.hashCode());
135                 result = prime * result + ((description == null) ? 0 : description.hashCode());
136                 result = prime * result + ((name == null) ? 0 : name.hashCode());
137                 result = prime * result + ((type == null) ? 0 : type.hashCode());
138                 result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
139                 result = prime * result + ((status == null) ? 0 : status.hashCode());
140                 result = prime * result + ((schema == null) ? 0 : schema.hashCode());
141                 return result;
142         }
143
144         @Override
145         public boolean equals(Object obj) {
146                 boolean equals = true;
147                 if (this == obj) {
148                         return true;
149                 }
150                 if (obj == null || getClass() != obj.getClass()) {
151                         return false;
152                 }
153
154                 AttributeDataDefinition other = (AttributeDataDefinition) obj;
155                 if (!Objects.equals(defaultValue, other.defaultValue)) {
156                         equals = false;
157                 } else if (!Objects.equals(value, other.value)) {
158                         equals = false;
159                 } else if (!Objects.equals(description, other.description)) {
160                         equals = false;
161                 } else if (!Objects.equals(name, other.name)) {
162                         equals = false;
163                 } else if (!Objects.equals(type, other.type)) {
164                         equals = false;
165                 } else if (!Objects.equals(uniqueId, other.uniqueId)) {
166                         equals = false;
167                 } else if (!Objects.equals(status, other.status)) {
168                         equals = false;
169                 } else if (!Objects.equals(schema, other.schema)) {
170                         equals = false;
171                 }
172                 return equals;
173         }
174
175         @Override
176         public String toString() {
177                 return "AttributeDataDefinition [uniqueId=" + uniqueId + ", name=" + name + ", type=" + type + ", description="
178                                 + description + ", defaultValue=" + defaultValue + ", value=" + value + ", status=" + status
179                                 + ", entrySchema=" + schema + "]";
180         }
181
182         public String getValue() {
183                 return value;
184         }
185
186         public void setValue(String value) {
187                 this.value = value;
188         }
189         
190         @Override
191         public Object getToscaPresentationValue(JsonPresentationFields field) {
192                 switch (field) {
193                 case NAME:
194                         return name;
195                 case UNIQUE_ID:
196                         return uniqueId;                
197                 case TYPE:
198                         return type;
199                 case DESCRIPTION:
200                         return description;
201                 case VALUE:
202                         return value;
203                 case DEFAULT_VALUE:
204                         return defaultValue;
205                 default:
206                         return super.getToscaPresentationValue(field);
207                 }
208         }
209 }