javolution.util.internal.map.MapEntryImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javolution-core-java-msftbx
Show all versions of javolution-core-java-msftbx
Only the Java Core part of Javolution library, with slight modifications for use in MSFTBX.
The newest version!
/*
* Javolution - Java(TM) Solution for Real-Time and Embedded Systems
* Copyright (C) 2012 - Javolution (http://javolution.org/)
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software is
* freely granted, provided that this notice is preserved.
*/
package javolution.util.internal.map;
import java.util.Map;
/**
* The hash map entry implementation (not serializable).
*/
final class MapEntryImpl implements Map.Entry {
int hash;
K key;
MapEntryImpl next;
MapEntryImpl previous;
V value;
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
@Override
public V setValue(V value) {
V oldValue = this.value;
this.value = value;
return oldValue;
}
@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
// As per Map.Entry contract.
if (!(obj instanceof Map.Entry)) return false;
Map.Entry that = (Map.Entry) obj;
return (this.getKey()==null ?
that.getKey()==null : this.getKey().equals(that.getKey())) &&
(this.getValue()==null ?
that.getValue()==null : this.getValue().equals(that.getValue()));
}
@Override
public int hashCode() {
// As per Map.Entry contract.
return (getKey()==null ? 0 : getKey().hashCode()) ^
(getValue()==null ? 0 : getValue().hashCode());
}
}