
com.alachisoft.ncache.client.internal.caching.Entry Maven / Gradle / Ivy
package com.alachisoft.ncache.client.internal.caching;
// region Entry
import java.util.Map;
/**
* @param
* @param
*/
public class Entry implements Map.Entry {
/**
*
*/
K key;
/**
*
*/
V value;
/**
* @param key
* @param value
*/
protected Entry(K key, V value) {
this.key = key;
this.value = value;
}
/**
*
*/
protected Entry() {
}
/**
* @return
*/
@Override
protected Object clone() {
return new Entry(/*hash,*/key, value/*,
* (next==null ? null : (Entry) next.clone())*/);
}
/**
* @return
*/
public K getKey() {
return key;
}
/**
* @param key
*/
public void setKey(K key) {
if (key == null) {
throw new IllegalArgumentException("Value cannot be null."+System.lineSeparator()+"Parameter name: key");
}
this.key = key;
}
/**
* @return
*/
public V getValue() {
return value;
}
/**
* @param value
* @return
*/
public V setValue(V value) {
// if(value == null) {
// throw new NullPointerException();
// }
V oldValue = this.value;
this.value = value;
return oldValue;
}
/**
* @param o
* @return
*/
@Override
public boolean equals(Object o) {
if (!(o instanceof Map.Entry)) {
return false;
}
Map.Entry e = (Map.Entry) o;
return (key == null ? e.getKey() == null : key.equals(e.getKey()))
&& (value == null ? e.getValue() == null : value.equals(e.getValue()));
}
/**
* @return
*/
@Override
public String toString() {
return key.toString() + "=" + (value != null ? value.toString() : "null");
}
}
///endregion
© 2015 - 2025 Weber Informatics LLC | Privacy Policy