The following information pertains to marshalling instances of java.util.HashMap
.
The MarshallerFactory
(in the Marshaller project) contains keys which are instances of
java.lang.Class
. By directly supporting the marshalling of keys in a HashMap
that are instances of Class
, the Marshaller itself can be marshalled,
producing documentation on all the keys and all the built-in marshallers.
public void testHashMapOfClasses() throws Exception { Marshaller marshaller = new Marshaller( Marshaller.FQCN_NEVER, Marshaller.SHOW_ACTUAL_TYPE); HashMap hashMap = new HashMap(); hashMap.put(String.class, "String"); hashMap.put(Integer.class, "Integer"); hashMap.put(Long.class, "Long"); Map map = marshaller.marshal(hashMap); BufferedWriter bw = new BufferedWriter(new FileWriter("c:\\temp\\hashmap-of-classes.mm")); map.marshal(bw); bw.close(); }