1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.api.util;
17
18 import org.apache.commons.lang.builder.CompareToBuilder;
19 import org.apache.commons.lang.builder.EqualsBuilder;
20 import org.apache.commons.lang.builder.HashCodeBuilder;
21 import org.apache.commons.lang.builder.ToStringBuilder;
22
23 import java.util.Map;
24
25
26
27
28
29
30
31
32
33
34 public final class ConcreteKeyValue extends AbstractKeyValue implements Comparable<KeyValue> {
35 private static final long serialVersionUID = 1176799455504861488L;
36
37 public ConcreteKeyValue() {
38 super();
39 }
40
41 public ConcreteKeyValue(String key, String value) {
42 super(key, value);
43 }
44
45 public ConcreteKeyValue(KeyValue keyValue) {
46 super(keyValue);
47 }
48
49 public ConcreteKeyValue(Map.Entry<String, String> entry) {
50 super(entry);
51 }
52
53 public void setKey(String key) {
54 this.key = key;
55 }
56
57 public void setValue(String value) {
58 this.value = value;
59 }
60
61 @Override
62 public int compareTo(KeyValue o) {
63 if (o == null) {
64 throw new NullPointerException("o is null");
65 }
66
67 return new CompareToBuilder()
68 .append(this.getValue(), o.getValue(), String.CASE_INSENSITIVE_ORDER)
69 .append(this.getKey(), o.getKey(), String.CASE_INSENSITIVE_ORDER)
70 .toComparison();
71 }
72
73 @Override
74 public int hashCode() {
75 return HashCodeBuilder.reflectionHashCode(this);
76 }
77
78 @Override
79 public boolean equals(Object obj) {
80 return EqualsBuilder.reflectionEquals(obj, this);
81 }
82
83 @Override
84 public String toString() {
85 return ToStringBuilder.reflectionToString(this);
86 }
87 }