if (val instanceof DBRef && field.isRef()) {
return unpackRef((DBRef)val, field.getType());
}
MongoEntity en = Mongos.entity(field.getMirror().getType());
if (en instanceof StaticMongoEntity)
return en.toObject((DBObject) val);
Map<String, Object> map = (Map<String, Object>) ((DBObject) val).toMap();
return Lang.map2Object(map, field.getType());
}
}