aQute.lib.json.MapHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bnd Show documentation
Show all versions of bnd Show documentation
A command line utility and Ant plugin to wrap, build, or examine bundles.
package aQute.lib.json;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
public class MapHandler extends Handler {
final Class< ? > rawClass;
final Type keyType;
final Type valueType;
MapHandler(Class< ? > rawClass, Type keyType, Type valueType) {
this.keyType = keyType;
this.valueType = valueType;
if (rawClass.isInterface()) {
if (rawClass.isAssignableFrom(HashMap.class))
rawClass = HashMap.class;
else if (rawClass.isAssignableFrom(TreeMap.class))
rawClass = TreeMap.class;
else if (rawClass.isAssignableFrom(Hashtable.class))
rawClass = Hashtable.class;
else if (rawClass.isAssignableFrom(LinkedHashMap.class))
rawClass = LinkedHashMap.class;
else if (rawClass.isAssignableFrom(Dictionary.class))
rawClass = Hashtable.class;
else
throw new IllegalArgumentException("Unknown map interface: " + rawClass);
}
this.rawClass = rawClass;
}
@Override
void encode(Encoder app, Object object, Map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy