All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.qatools.mongodb.MongoBasicStorage Maven / Gradle / Ivy

package ru.qatools.mongodb;

import org.bson.Document;
import ru.qatools.mongodb.error.InternalRepositoryException;

/**
 * @author Ilya Sadykov
 */
public interface MongoBasicStorage {

    @SuppressWarnings("unchecked")
    default T getObject(Document doc, Class expectedClass) {
        try {
            if (doc == null) {
                return null;
            }
            return getDeserializer().fromDBObject(doc, expectedClass);
        } catch (Exception e) {
            throw new InternalRepositoryException("Failed to deserialize object from bson! ", e);
        }
    }

    Serializer getSerializer();

    Deserializer getDeserializer();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy