| 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 | |
|
| 33 | |
public ConcreteKeyValue() { |
| 34 | 0 | super(); |
| 35 | 0 | } |
| 36 | |
|
| 37 | |
public ConcreteKeyValue(String key, String value) { |
| 38 | 0 | super(key, value); |
| 39 | 0 | } |
| 40 | |
|
| 41 | |
public ConcreteKeyValue(KeyValue keyValue) { |
| 42 | 0 | super(keyValue); |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
public ConcreteKeyValue(Map.Entry<String, String> entry) { |
| 46 | 0 | super(entry); |
| 47 | 0 | } |
| 48 | |
|
| 49 | |
public void setKey(String key) { |
| 50 | 0 | this.key = key; |
| 51 | 0 | } |
| 52 | |
|
| 53 | |
public void setValue(String value) { |
| 54 | 0 | this.value = value; |
| 55 | 0 | } |
| 56 | |
|
| 57 | |
@Override |
| 58 | |
public int compareTo(KeyValue o) { |
| 59 | 0 | if (o == null) { |
| 60 | 0 | throw new NullPointerException("o is null"); |
| 61 | |
} |
| 62 | |
|
| 63 | 0 | return new CompareToBuilder() |
| 64 | |
.append(this.getValue(), o.getValue(), String.CASE_INSENSITIVE_ORDER) |
| 65 | |
.append(this.getKey(), o.getKey(), String.CASE_INSENSITIVE_ORDER) |
| 66 | |
.toComparison(); |
| 67 | |
} |
| 68 | |
|
| 69 | |
@Override |
| 70 | |
public int hashCode() { |
| 71 | 0 | final int prime = 31; |
| 72 | 0 | int result = 1; |
| 73 | 0 | result = prime * result |
| 74 | |
+ ((this.getKey() == null) ? 0 : this.getKey().hashCode()); |
| 75 | 0 | result = prime * result |
| 76 | |
+ ((this.getValue() == null) ? 0 : this.getValue().hashCode()); |
| 77 | 0 | return result; |
| 78 | |
} |
| 79 | |
|
| 80 | |
@Override |
| 81 | |
public boolean equals(Object obj) { |
| 82 | 0 | if (this == obj) |
| 83 | 0 | return true; |
| 84 | 0 | if (obj == null) |
| 85 | 0 | return false; |
| 86 | 0 | if (getClass() != obj.getClass()) |
| 87 | 0 | return false; |
| 88 | 0 | KeyValue other = (KeyValue) obj; |
| 89 | 0 | if (this.getKey() == null) { |
| 90 | 0 | if (other.getKey() != null) |
| 91 | 0 | return false; |
| 92 | 0 | } else if (!this.getKey().equals(other.getKey())) |
| 93 | 0 | return false; |
| 94 | 0 | if (this.getValue() == null) { |
| 95 | 0 | if (other.getValue() != null) |
| 96 | 0 | return false; |
| 97 | 0 | } else if (!this.getValue().equals(other.getValue())) |
| 98 | 0 | return false; |
| 99 | 0 | return true; |
| 100 | |
} |
| 101 | |
|
| 102 | |
@Override |
| 103 | |
public String toString() { |
| 104 | 0 | return "ConcreteKeyValue [getKey()=" + this.getKey() + ", getValue()=" |
| 105 | |
+ this.getValue() + "]"; |
| 106 | |
} |
| 107 | |
} |