1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.util; |
17 | |
|
18 | |
import java.util.Map; |
19 | |
|
20 | |
import org.apache.commons.lang.builder.CompareToBuilder; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 0 | public final class ConcreteKeyValue extends AbstractKeyValue implements Comparable<KeyValue> { |
32 | |
private static final long serialVersionUID = 1176799455504861488L; |
33 | |
|
34 | |
public ConcreteKeyValue() { |
35 | 0 | super(); |
36 | 0 | } |
37 | |
|
38 | |
public ConcreteKeyValue(String key, String value) { |
39 | 0 | super(key, value); |
40 | 0 | } |
41 | |
|
42 | |
public ConcreteKeyValue(KeyValue keyValue) { |
43 | 0 | super(keyValue); |
44 | 0 | } |
45 | |
|
46 | |
public ConcreteKeyValue(Map.Entry<String, String> entry) { |
47 | 0 | super(entry); |
48 | 0 | } |
49 | |
|
50 | |
public void setKey(String key) { |
51 | 0 | this.key = key; |
52 | 0 | } |
53 | |
|
54 | |
public void setValue(String value) { |
55 | 0 | this.value = value; |
56 | 0 | } |
57 | |
|
58 | |
@Override |
59 | |
public int compareTo(KeyValue o) { |
60 | 0 | if (o == null) { |
61 | 0 | throw new NullPointerException("o is null"); |
62 | |
} |
63 | |
|
64 | 0 | return new CompareToBuilder() |
65 | |
.append(this.getValue(), o.getValue(), String.CASE_INSENSITIVE_ORDER) |
66 | |
.append(this.getKey(), o.getKey(), String.CASE_INSENSITIVE_ORDER) |
67 | |
.toComparison(); |
68 | |
} |
69 | |
|
70 | |
@Override |
71 | |
public int hashCode() { |
72 | 0 | final int prime = 31; |
73 | 0 | int result = 1; |
74 | 0 | result = prime * result |
75 | |
+ ((this.getKey() == null) ? 0 : this.getKey().hashCode()); |
76 | 0 | result = prime * result |
77 | |
+ ((this.getValue() == null) ? 0 : this.getValue().hashCode()); |
78 | 0 | return result; |
79 | |
} |
80 | |
|
81 | |
@Override |
82 | |
public boolean equals(Object obj) { |
83 | 0 | if (this == obj) |
84 | 0 | return true; |
85 | 0 | if (obj == null) |
86 | 0 | return false; |
87 | 0 | if (getClass() != obj.getClass()) |
88 | 0 | return false; |
89 | 0 | KeyValue other = (KeyValue) obj; |
90 | 0 | if (this.getKey() == null) { |
91 | 0 | if (other.getKey() != null) |
92 | 0 | return false; |
93 | 0 | } else if (!this.getKey().equals(other.getKey())) |
94 | 0 | return false; |
95 | 0 | if (this.getValue() == null) { |
96 | 0 | if (other.getValue() != null) |
97 | 0 | return false; |
98 | 0 | } else if (!this.getValue().equals(other.getValue())) |
99 | 0 | return false; |
100 | 0 | return true; |
101 | |
} |
102 | |
|
103 | |
@Override |
104 | |
public String toString() { |
105 | 0 | return "ConcreteKeyValue [getKey()=" + this.getKey() + ", getValue()=" |
106 | |
+ this.getValue() + "]"; |
107 | |
} |
108 | |
} |