@Override
public Object decode(Class targetClass, Object fromDBObject, MappedField f) throws MappingException {
if (fromDBObject == null) return null;
if (!((fromDBObject instanceof Binary) || (fromDBObject instanceof byte[]))) {
throw new MappingException("The stored data is not a DBBinary or byte[] instance for " + f.getFullName()
+ " ; it is a " + fromDBObject.getClass().getName());
}
try {
boolean useCompression = !f.getAnnotation(Serialized.class).disableCompression();
return Serializer.deserialize(fromDBObject, useCompression);
} catch (IOException e) {
throw new MappingException("While deserializing to " + f.getFullName(), e);
} catch (ClassNotFoundException e) {
throw new MappingException("While deserializing to " + f.getFullName(), e);
}
}