1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package ch.hortis.sonar.service;
21
22 import ch.hortis.sonar.model.Metric;
23 import ch.hortis.sonar.model.ProjectMeasure;
24 import ch.hortis.sonar.model.Rule;
25 import org.apache.commons.lang.builder.EqualsBuilder;
26 import org.apache.commons.lang.builder.HashCodeBuilder;
27
28 public class MeasureKey implements Cloneable {
29 protected Metric metric;
30 protected Integer rulesCategoryId;
31 protected Rule rule;
32
33 public MeasureKey(Metric metric, Integer rulesCategoryId, Rule rule) {
34 this.metric = metric;
35 this.rulesCategoryId = rulesCategoryId;
36 this.rule = rule;
37 }
38
39 public MeasureKey(Metric metric) {
40 this(metric, (Integer)null, null);
41 }
42
43 public MeasureKey(ProjectMeasure measure) {
44 this(measure.getMetric(), measure.getRulesCategoryId(), measure.getRule());
45 }
46
47 public boolean equals(Object obj) {
48 if (!(obj instanceof MeasureKey)) {
49 return false;
50 }
51 if (this == obj) {
52 return true;
53 }
54 MeasureKey other = (MeasureKey) obj;
55 return new EqualsBuilder().
56 append(metric, other.metric).
57 append(rulesCategoryId, other.rulesCategoryId).
58 append(rule, other.rule).
59 isEquals();
60 }
61
62 public int hashCode() {
63 return new HashCodeBuilder(17, 37).
64 append(metric).
65 append(rulesCategoryId).
66 append(rule).
67 toHashCode();
68 }
69
70 public Object clone() {
71 return new MeasureKey(this.metric, this.rulesCategoryId, this.rule);
72 }
73
74
75 public Metric getMetric() {
76 return metric;
77 }
78
79 public MeasureKey setMetric(Metric metric) {
80 this.metric = metric;
81 return this;
82 }
83
84 public Integer getRulesCategoryId() {
85 return rulesCategoryId;
86 }
87
88 public MeasureKey setRulesCategoryId(Integer id) {
89 this.rulesCategoryId = id;
90 return this;
91 }
92
93 public Rule getRule() {
94 return rule;
95 }
96
97 public MeasureKey setRule(Rule rule) {
98 this.rule = rule;
99 return this;
100 }
101
102 }