1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package ch.hortis.sonar.model;
21
22 import org.apache.commons.lang.builder.EqualsBuilder;
23 import org.apache.commons.lang.builder.HashCodeBuilder;
24 import org.apache.commons.lang.builder.ToStringBuilder;
25 import org.hibernate.annotations.Cache;
26 import org.hibernate.annotations.CacheConcurrencyStrategy;
27 import org.hibernate.annotations.Immutable;
28
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.NamedQueries;
35 import javax.persistence.NamedQuery;
36 import javax.persistence.SequenceGenerator;
37 import javax.persistence.Table;
38
39 @Immutable
40 @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
41 @Entity
42 @Table(name = "rules_categories")
43 @NamedQueries(
44 {@NamedQuery(name = RulesCategory.SQL_SELECT_ALL, query = "SELECT r FROM RulesCategory r")}
45 )
46 public class RulesCategory {
47
48 public final static String SQL_SELECT_ALL = "RulesCategory.selectAll";
49
50 @Id
51 @Column(name = "id")
52 @SequenceGenerator(name = "RULES_CATEGORIES_SEQ", sequenceName = "RULES_CATEGORIES_SEQ")
53 @GeneratedValue(strategy = GenerationType.AUTO, generator = "RULES_CATEGORIES_SEQ")
54 private Integer id;
55
56 @Column(name = "name", updatable = false, nullable = false)
57 private String name;
58
59 @Column(name = "description", updatable = false, nullable = true)
60 private String description;
61
62 public RulesCategory(String name) {
63 this.name = name;
64 }
65
66 public RulesCategory(String name, String description) {
67 this.name = name;
68 this.description = description;
69 }
70
71 public RulesCategory() {
72 }
73
74 public Integer getId() {
75 return id;
76 }
77
78 public void setId(Integer id) {
79 this.id = id;
80 }
81
82 public String getName() {
83 return name;
84 }
85
86 public void setName(String name) {
87 this.name = name;
88 }
89
90 public String getDescription() {
91 return description;
92 }
93
94 public void setDescription(String description) {
95 this.description = description;
96 }
97
98 public boolean equals(Object obj) {
99 if (!(obj instanceof RulesCategory)) {
100 return false;
101 }
102 if (this == obj) {
103 return true;
104 }
105 RulesCategory other = (RulesCategory) obj;
106 return new EqualsBuilder()
107 .append(name, other.getName()).isEquals();
108 }
109
110 public int hashCode() {
111 return new HashCodeBuilder(17, 37)
112 .append(name)
113 .toHashCode();
114 }
115
116 public String toString() {
117 return new ToStringBuilder(this)
118 .append("id", id)
119 .append("name", name)
120 .append("desc", description)
121 .toString();
122 }
123
124 }