![JAR search and dependency download from the Maven repository](/logo.png)
de.tsl2.nano.collection.Entry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.datastructure Show documentation
Show all versions of tsl2.nano.datastructure Show documentation
optimized implementations for trees, collections, arrays, historized input
The newest version!
package de.tsl2.nano.collection;
import java.io.Serializable;
import java.util.Map;
import de.tsl2.nano.core.util.Util;
/**
* part of {@link MapEntrySet}. as the hashmap implementation doesn't make Map.Entry serializable, we have to write our
* own entry class.
*
* @param
* @param
* @author Tom
* @version $Revision$
*/
public class Entry implements Map.Entry, Serializable {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
K key;
V value;
boolean sync;
Map map;
/**
* constructor no map connection available. {@link MapEntrySet} has to collect this entry on adding.
*/
public Entry() {
}
Entry(Map.Entry src, boolean sync, Map map) {
key = src.getKey();
value = src.getValue();
this.sync = sync;
this.map = map;
}
/**
* constructor
*
* @param key
* @param value
*/
public Entry(K key, V value) {
super();
this.key = key;
this.value = value;
}
@Override
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
@Override
public V getValue() {
return value;
}
@Override
public V setValue(V value) {
this.value = value;
if (sync) {
map.put(key, value);
}
return value;
}
@Override
public String toString() {
return Util.toString(getClass(), key, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy