| 1 18 package net.sf.uitags.util; 19 20 import java.util.Map ; 21 22 29 public final class ValueLabelPair implements Map.Entry { 30 33 private Object value; 34 37 private Object label; 38 39 45 public ValueLabelPair(Object value, Object label) { 46 super(); 47 if (value == null) { 48 throw new NullPointerException ("Value cannot be null"); 49 } 50 this.value = value; 51 this.label = label; 52 } 53 54 60 public Object setValue(Object value) { 61 this.value = value; 62 return this.value; 63 } 64 65 70 public Object getKey() { 71 return this.value; 72 } 73 74 79 public Object getValue() { 80 return this.label; 81 } 82 83 90 public String getValueAsString() { 91 return String.valueOf(this.value); 92 } 93 94 101 public String getLabelAsString() { 102 return String.valueOf(this.label); 103 } 104 105 106 public boolean equals(Object obj) { 107 if (this == obj) { 108 return true; 109 } 110 111 if (!(obj instanceof ValueLabelPair)) { 112 return false; 113 } 114 115 ValueLabelPair temp = (ValueLabelPair) obj; 116 return (this.value == null ? 117 temp.value == null : this.value.equals(temp.value)); 118 } 119 120 121 public int hashCode() { 122 int hashCode = (this.value == null ? 0 : this.value.hashCode()); 123 return hashCode; 124 } 125 } 126 | Popular Tags |