aQute.libg.map.MAP Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aQute.libg Show documentation
Show all versions of aQute.libg Show documentation
A library to be statically linked. Contains many small utilities. This bundle should not be installed in a framework, it is compile only.
package aQute.libg.map;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Easy way to build a map: Map s = MAP.$("a",2).$("b",3);
*/
public class MAP {
static public class MAPX extends LinkedHashMap {
private static final long serialVersionUID = 1L;
public MAPX $(K key, V value) {
put(key, value);
return this;
}
public MAPX $(Map all) {
putAll(all);
return this;
}
public Hashtable asHashtable() {
return new Hashtable(this);
}
}
public static MAPX $(Kx key, Vx value) {
MAPX map = new MAPX();
map.put(key, value);
return map;
}
public Map dictionary(Dictionary dict) {
Map map = new LinkedHashMap();
for (Enumeration e = dict.keys(); e.hasMoreElements();) {
K k = e.nextElement();
V v = dict.get(k);
map.put(k, v);
}
return map;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy