1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.sonar.commons.rules;
21
22 import ch.hortis.sonar.model.Rule;
23 import org.apache.commons.lang.builder.EqualsBuilder;
24 import org.apache.commons.lang.builder.HashCodeBuilder;
25 import org.apache.commons.lang.builder.ToStringBuilder;
26
27 import javax.persistence.*;
28
29 @Entity
30 @Table(name = "rules_parameters")
31 public class RuleParam {
32
33 @Id
34 @Column(name = "id")
35 @SequenceGenerator(name = "RULES_PARAMETERS_SEQ", sequenceName = "RULES_PARAMETERS_SEQ")
36 @GeneratedValue(strategy = GenerationType.AUTO, generator = "RULES_PARAMETERS_SEQ")
37 private Integer id;
38
39 @ManyToOne(fetch = FetchType.LAZY)
40 @JoinColumn(name = "rule_id")
41 private Rule rule;
42
43 @Column(name = "name", updatable = true, nullable = false, length = 128)
44 private String key;
45
46 @Column(name = "description", updatable = true, nullable = true, length = 4000)
47 private String description;
48
49 @Column(name = "param_type", updatable = true, nullable = false, length = 512)
50 private String type;
51
52 @Column(name = "default_value", updatable = true, nullable = true, length = 4000)
53 private String defaultValue;
54
55
56 public RuleParam() {
57 }
58
59 public RuleParam(Rule rule, String key, String description, String type, String defaultValue) {
60 this.rule = rule;
61 this.key = key;
62 this.description = description;
63 this.type = type;
64 this.defaultValue = defaultValue;
65 }
66
67 public Integer getId() {
68 return id;
69 }
70
71 public void setId(Integer id) {
72 this.id = id;
73 }
74
75 public Rule getRule() {
76 return rule;
77 }
78
79 public void setRule(Rule rule) {
80 this.rule = rule;
81 }
82
83 public String getKey() {
84 return key;
85 }
86
87 public void setKey(String key) {
88 this.key = key;
89 }
90
91 public String getDescription() {
92 return description;
93 }
94
95 public void setDescription(String description) {
96 this.description = description;
97 }
98
99 public String getType() {
100 return type;
101 }
102
103 public void setType(String type) {
104 this.type = type;
105 }
106
107 public String getDefaultValue() {
108 return defaultValue;
109 }
110
111 public void setDefaultValue(String defaultValue) {
112 this.defaultValue = defaultValue;
113 }
114
115 public boolean equals(Object obj) {
116 if (!(obj instanceof RuleParam)) {
117 return false;
118 }
119 if (this == obj) {
120 return true;
121 }
122 RuleParam other = (RuleParam) obj;
123 return new EqualsBuilder()
124 .append(rule, other.getRule())
125 .append(key, other.getKey()).isEquals();
126 }
127
128 public int hashCode() {
129 return new HashCodeBuilder(17, 37)
130 .append(rule)
131 .append(key)
132 .toHashCode();
133 }
134
135 public String toString() {
136 return new ToStringBuilder(this)
137 .append("id", id)
138 .append("key",key)
139 .append("desc", description)
140 .append("type", type)
141 .append("default", defaultValue)
142 .toString();
143 }
144 }