Merge "change management new filter tests"
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / CategoryParameter.java
1 package org.onap.vid.model;
2
3 /*-
4  * ============LICENSE_START=======================================================
5  * VID
6  * ================================================================================
7  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
8  * Modifications Copyright (C) 2018 - 2019 Nokia. All rights reserved.
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 import java.util.Collections;
25 import java.util.HashSet;
26 import java.util.Objects;
27 import java.util.Set;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.EnumType;
31 import javax.persistence.Enumerated;
32 import javax.persistence.FetchType;
33 import javax.persistence.GeneratedValue;
34 import javax.persistence.GenerationType;
35 import javax.persistence.Id;
36 import javax.persistence.OneToMany;
37 import javax.persistence.Table;
38 import javax.persistence.UniqueConstraint;
39
40 @Entity
41 @Table(name = "vid_category_parameter", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
42 public class CategoryParameter extends VidBaseEntity {
43
44     public enum Family {
45         PARAMETER_STANDARDIZATION,
46         TENANT_ISOLATION
47     }
48
49     private String name;
50     private boolean idSupported;
51
52     @Column(name = "FAMILY")
53     @Enumerated(EnumType.STRING)
54     private String family;
55
56     public String getFamily() {
57         return family;
58     }
59
60     public void setFamily(String family) {
61         this.family = family;
62     }
63
64     private Set<CategoryParameterOption> options = new HashSet<>(0);
65
66     @Override
67     @Id
68     @GeneratedValue(strategy = GenerationType.IDENTITY)
69     @Column(name = "CATEGORY_ID")
70     public Long getId() {
71         return super.getId();
72     }
73
74     @Column(name = "NAME", unique = true, nullable = false, length=50)
75     public String getName() {
76         return name;
77     }
78
79     public void setName(String name) {
80         this.name = name;
81     }
82
83     @OneToMany(fetch = FetchType.EAGER, mappedBy = "categoryParameter")
84     public Set<CategoryParameterOption> getOptions() {
85         return Collections.unmodifiableSet(options);
86     }
87
88     public void setOptions(Set<CategoryParameterOption> options) {
89         this.options = options;
90     }
91
92     public boolean addOption(CategoryParameterOption option) {
93         return options.add(option);
94     }
95
96     @Column(name = "ID_SUPPORTED")
97     public boolean isIdSupported() {
98         return idSupported;
99     }
100
101     public void setIdSupported(boolean idSupported) {
102         this.idSupported = idSupported;
103     }
104
105     @Override
106     public boolean equals(Object o) {
107         if (this == o) return true;
108         if (o == null || this.getClass() != o.getClass()) return false;
109         CategoryParameter that = (CategoryParameter) o;
110         return this.idSupported == that.idSupported &&
111                 Objects.equals(this.name, that.name) &&
112                 Objects.equals(this.family, that.family) &&
113                 Objects.equals(this.options, that.options);
114     }
115
116     @Override
117     public int hashCode() {
118         return Objects.hash(this.name, this.idSupported, this.family, this.options);
119     }
120 }