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