@Override
 @SuppressWarnings("unchecked")
 public void pack(Packer pk, Object obj) throws IOException {
   if (obj instanceof Map) {
     Map d = (Map) obj;
     pk.packArray(fields.length);
     for (int i = 0; i < fields.length; ++i) {
       FieldSchema f = fields[i];
       f.getSchema().pack(pk, d.get(f.getName()));
     }
   } else if (obj == null) {
     pk.packNil();
   } else {
     throw MessageTypeException.invalidConvert(obj, this);
   }
 }
 @Override
 public Object convert(Object obj) throws MessageTypeException {
   if (obj instanceof Collection) {
     // FIXME optimize
     return createFromArray(((Collection) obj).toArray());
   } else if (obj instanceof Map) {
     HashMap<String, Object> m = new HashMap<String, Object>(fields.length);
     Map d = (Map) obj;
     for (int i = 0; i < fields.length; ++i) {
       FieldSchema f = fields[i];
       String fieldName = f.getName();
       m.put(fieldName, f.getSchema().convert(d.get(fieldName)));
     }
     return m;
   } else {
     throw MessageTypeException.invalidConvert(obj, this);
   }
 }