Increasing test coverage for vid.mso.rest
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / CategoryParameterOption.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.onap.vid.model;
22
23 import org.onap.portalsdk.core.domain.support.DomainVo;
24
25 import javax.persistence.*;
26 import java.io.Serializable;
27 import java.util.Date;
28 import java.util.Set;
29
30 @Entity
31 @Table(name = "vid_category_parameter_option")
32 public class CategoryParameterOption extends DomainVo {
33
34     private String appId;
35     private String name;
36
37     private CategoryParameter categoryParameter;
38
39     public CategoryParameterOption() {
40     }
41
42     public CategoryParameterOption(String appId, String name, CategoryParameter categoryParameter) {
43         setAppId(appId);
44         setName(name);
45         setCategoryParameter(categoryParameter);
46     }
47
48     @Id
49     @GeneratedValue(strategy = GenerationType.IDENTITY)
50     @Column(name = "CATEGORY_OPT_DB_ID")
51     public Long getId() {
52         return id;
53     }
54
55     @Column(name = "CATEGORY_OPT_APP_ID")
56     public String getAppId() {
57         return appId;
58     }
59
60     public void setAppId(String appId) {
61         this.appId = appId;
62     }
63
64     @Column(name = "NAME")
65     public String getName() {
66         return name;
67     }
68
69     public void setName(String name) {
70         this.name = name;
71     }
72
73     @ManyToOne
74     @JoinColumn(name="CATEGORY_ID", nullable=false)
75     public CategoryParameter getCategoryParameter() {
76         return categoryParameter;
77     }
78
79     public void setCategoryParameter(CategoryParameter categoryParameter) {
80         this.categoryParameter = categoryParameter;
81     }
82
83     @Override
84     @Column(name = "CREATED_DATE")
85     public Date getCreated() {
86         return super.getCreated();
87     }
88
89     @Override
90     @Column(name = "MODIFIED_DATE")
91     public Date getModified() {
92         return super.getModified();
93     }
94
95     @Override
96     @Transient
97     public Long getCreatedId() {
98         return super.getCreatedId();
99     }
100
101     @Override
102     @Transient
103     public Long getModifiedId() {
104         return super.getModifiedId();
105     }
106
107     @Override
108     @Transient
109     public Serializable getAuditUserId() {
110         return super.getAuditUserId();
111     }
112
113     @Override
114     @Transient
115     public Long getRowNum() {
116         return super.getRowNum();
117     }
118
119     @Override
120     @Transient
121     public Set getAuditTrail() {
122         return super.getAuditTrail();
123     }
124
125     @Override
126     public boolean equals(Object o) {
127         if (this == o) return true;
128         if (o == null || getClass() != o.getClass()) return false;
129
130         CategoryParameterOption that = (CategoryParameterOption) o;
131
132         if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) return false;
133         if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
134         return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter()) : that.getCategoryParameter() == null;
135     }
136
137     @Override
138     public int hashCode() {
139         int result = getAppId() != null ? getAppId().hashCode() : 0;
140         result = 31 * result + (getName() != null ? getName().hashCode() : 0);
141         result = 31 * result + (getCategoryParameter() != null ? getCategoryParameter().hashCode() : 0);
142         return result;
143     }
144
145     @Override
146     public String toString() {
147         return "CategoryParameterOption{" +
148                 "id=" + id +
149                 ", key='" + appId + '\'' +
150                 ", value='" + name + '\'' +
151                 ", categoryParameterId=" + categoryParameter.getId() +
152                 '}';
153     }
154 }