1 16 package org.apache.commons.chain.web; 17 18 19 import java.util.Map ; 20 21 22 28 29 public class MapEntry implements Map.Entry { 30 31 32 35 private Object key; 36 37 40 private Object value; 41 42 45 private boolean modifiable = false; 46 47 48 55 public MapEntry(Object key, Object value, boolean modifiable) { 56 this.key = key; 57 this.value = value; 58 this.modifiable = modifiable; 59 } 60 61 62 67 public Object getKey() { 68 return key; 69 } 70 71 72 77 public Object getValue() { 78 return value; 79 } 80 81 82 89 public Object setValue(Object val) { 90 if (modifiable) { 91 Object oldVal = this.value; 92 this.value = val; 93 return oldVal; 94 } else { 95 throw new UnsupportedOperationException (); 96 } 97 } 98 99 100 106 public boolean equals(Object o) { 107 if (o != null && o instanceof Map.Entry ) { 108 Map.Entry entry = (Map.Entry )o; 109 return (this.getKey() == null ? 110 entry.getKey() == null : this.getKey().equals(entry.getKey())) && 111 (this.getValue() == null ? 112 entry.getValue() == null : this.getValue().equals(entry.getValue())); 113 } 114 return false; 115 } 116 117 118 123 public int hashCode() { 124 return (this.getKey() == null ? 0 : this.getKey().hashCode()) ^ 125 (this.getValue() == null ? 0 : this.getValue().hashCode()); 126 } 127 } 128 | Popular Tags |