2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ===================================================================
24 package org.onap.clamp.tosca;
26 import com.google.gson.annotations.Expose;
27 import java.io.Serializable;
28 import java.util.HashSet;
30 import javax.persistence.Column;
31 import javax.persistence.Entity;
32 import javax.persistence.FetchType;
33 import javax.persistence.Id;
34 import javax.persistence.ManyToMany;
35 import javax.persistence.Table;
36 import org.onap.clamp.loop.common.AuditEntity;
39 * Represents a Dictionary Item.
42 @Table(name = "dictionary_elements")
43 public class DictionaryElement extends AuditEntity implements Serializable {
46 * The serial version id.
48 private static final long serialVersionUID = -286522707701388644L;
52 @Column(nullable = false, name = "short_name")
53 private String shortName;
56 @Column(nullable = false, name = "name")
60 @Column(nullable = false, name = "description")
61 private String description;
64 @Column(nullable = false, name = "type")
68 @Column(nullable = true, name = "subdictionary_name")
69 private String subDictionary;
71 @ManyToMany(mappedBy = "dictionaryElements", fetch = FetchType.EAGER)
72 private Set<Dictionary> usedByDictionaries = new HashSet<>();
79 public String getName() {
86 * @param name the name to set
88 public void setName(String name) {
95 * @return the shortName
97 public String getShortName() {
104 * @param shortName the shortName to set
106 public void setShortName(String shortName) {
107 this.shortName = shortName;
111 * description getter.
113 * @return the description
115 public String getDescription() {
120 * description setter.
122 * @param description the description to set
124 public void setDescription(String description) {
125 this.description = description;
133 public String getType() {
140 * @param type the type to set
142 public void setType(String type) {
147 * subDictionary getter.
149 * @return the subDictionary
151 public String getSubDictionary() {
152 return subDictionary;
156 * subDictionary setter.
158 * @param subDictionary the subDictionary to set
160 public void setSubDictionary(String subDictionary) {
161 this.subDictionary = subDictionary;
165 * usedByDictionaries getter.
167 * @return the usedByDictionaries
169 public Set<Dictionary> getUsedByDictionaries() {
170 return usedByDictionaries;
174 * usedByDictionaries setter.
176 * @param usedByDictionaries the usedByDictionaries to set
178 public void setUsedByDictionaries(Set<Dictionary> usedByDictionaries) {
179 this.usedByDictionaries = usedByDictionaries;
183 * Default Constructor.
185 public DictionaryElement() {
191 * @param name The Dictionary element name
192 * @param shortName The short name
193 * @param description The description
194 * @param type The type of element
195 * @param subDictionary The sub type
197 public DictionaryElement(String name, String shortName, String description, String type,
198 String subDictionary) {
200 this.shortName = shortName;
201 this.description = description;
203 this.subDictionary = subDictionary;
209 * @param name The Dictionary element name
210 * @param shortName The short name
211 * @param description The description
212 * @param type The type of element
213 * @param subDictionary The sub type
215 public DictionaryElement(String name, String shortName, String description, String type,
216 String subDictionary, Set<Dictionary> usedByDictionaries) {
218 this.shortName = shortName;
219 this.description = description;
221 this.subDictionary = subDictionary;
222 this.usedByDictionaries = usedByDictionaries;
226 public int hashCode() {
227 final int prime = 31;
229 result = prime * result + ((shortName == null) ? 0 : shortName.hashCode());
234 public boolean equals(Object obj) {
241 if (getClass() != obj.getClass()) {
244 DictionaryElement other = (DictionaryElement) obj;
245 if (shortName == null) {
246 if (other.shortName != null) {
249 } else if (!shortName.equals(other.shortName)) {