Add template and tosca model entities and repositories
[clamp.git] / src / main / java / org / onap / clamp / tosca / Dictionary.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights
6  *                             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  */
23
24 package org.onap.clamp.tosca;
25
26 import com.google.gson.annotations.Expose;
27
28 import java.io.Serializable;
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import javax.persistence.CascadeType;
33 import javax.persistence.Column;
34 import javax.persistence.Entity;
35 import javax.persistence.FetchType;
36 import javax.persistence.Id;
37 import javax.persistence.OneToMany;
38 import javax.persistence.Table;
39
40 import org.onap.clamp.loop.common.AuditEntity;
41
42 /**
43  * Represents Dictionary.
44  */
45
46 @Entity
47 @Table(name = "dictionary")
48 public class Dictionary extends AuditEntity implements Serializable {
49
50     /**
51      * The serial version id.
52      */
53     private static final long serialVersionUID = -286522707701388645L;
54
55     @Id
56     @Expose
57     @Column(nullable = false, name = "name", unique = true)
58     private String name;
59
60     @Expose
61     @Column(name = "dictionary_second_level")
62     private int secondLevelDictionary;
63
64     @Expose
65     @Column(name = "dictionary_type")
66     private String subDictionaryType;
67
68     @Expose
69     @OneToMany(mappedBy = "dictionary", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
70     private List<DictionaryElement> dictionaryElements = new ArrayList<>();
71
72     /**
73      * name getter.
74      * 
75      * @return the name
76      */
77     public String getName() {
78         return name;
79     }
80
81     /**
82      * name setter.
83      * 
84      * @param name the name to set
85      */
86     public void setName(String name) {
87         this.name = name;
88     }
89
90     /**
91      * secondLevelDictionary getter.
92      * 
93      * @return the secondLevelDictionary
94      */
95     public int getSecondLevelDictionary() {
96         return secondLevelDictionary;
97     }
98
99     /**
100      * secondLevelDictionary setter.
101      * 
102      * @param secondLevelDictionary the secondLevelDictionary to set
103      */
104     public void setSecondLevelDictionary(int secondLevelDictionary) {
105         this.secondLevelDictionary = secondLevelDictionary;
106     }
107
108     /**
109      * subDictionaryType getter.
110      * 
111      * @return the subDictionaryType
112      */
113     public String getSubDictionaryType() {
114         return subDictionaryType;
115     }
116
117     /**
118      * subDictionaryType setter.
119      * 
120      * @param subDictionaryType the subDictionaryType to set
121      */
122     public void setSubDictionaryType(String subDictionaryType) {
123         this.subDictionaryType = subDictionaryType;
124     }
125
126     /**
127      * dictionaryElements getter.
128      * 
129      * @return the dictionaryElements
130      */
131     public List<DictionaryElement> getDictionaryElements() {
132         return dictionaryElements;
133     }
134
135     /**
136      * dictionaryElements setter.
137      * 
138      * @param dictionaryElements the dictionaryElements to set
139      */
140     public void setDictionaryElements(List<DictionaryElement> dictionaryElements) {
141         this.dictionaryElements = dictionaryElements;
142     }
143
144     @Override
145     public int hashCode() {
146         final int prime = 31;
147         int result = 1;
148         result = prime * result + ((name == null) ? 0 : name.hashCode());
149         return result;
150     }
151
152     @Override
153     public boolean equals(Object obj) {
154         if (this == obj) {
155             return true;
156         }
157         if (obj == null) {
158             return false;
159         }
160         if (getClass() != obj.getClass()) {
161             return false;
162         }
163         Dictionary other = (Dictionary) obj;
164         if (name == null) {
165             if (other.name != null) {
166                 return false;
167             }
168         } else if (!name.equals(other.name)) {
169             return false;
170         }
171         return true;
172     }
173
174 }