1 16 package org.apache.commons.collections.keyvalue; 17 18 import java.util.Map ; 19 20 31 public abstract class AbstractMapEntry extends AbstractKeyValue implements Map.Entry { 32 33 39 protected AbstractMapEntry(Object key, Object value) { 40 super(key, value); 41 } 42 43 53 public Object setValue(Object value) { 54 Object answer = this.value; 55 this.value = value; 56 return answer; 57 } 58 59 67 public boolean equals(Object obj) { 68 if (obj == this) { 69 return true; 70 } 71 if (obj instanceof Map.Entry == false) { 72 return false; 73 } 74 Map.Entry other = (Map.Entry ) obj; 75 return 76 (getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) && 77 (getValue() == null ? other.getValue() == null : getValue().equals(other.getValue())); 78 } 79 80 87 public int hashCode() { 88 return (getKey() == null ? 0 : getKey().hashCode()) ^ 89 (getValue() == null ? 0 : getValue().hashCode()); 90 } 91 92 } 93 | Popular Tags |