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

clients.mongodb.codec.DocumentCodecProvider Maven / Gradle / Ivy

The newest version!
package clients.mongodb.codec;

import com.github.simondan.definition.AbstractStorableObject;
import org.bson.codecs.Codec;
import org.bson.codecs.configuration.*;

/**
 * Provider für den CustomDocumentCodec, um eine Mongo-DBCollection mit eigenen Implementierungen von Document
 * mit passenden Konvertern für die Dokumente zu versorgen
 *
 * @author Simon Danner, 19.12.2015
 */
public class DocumentCodecProvider implements CodecProvider
{
  private Class objectClass;

  public DocumentCodecProvider(Class pObjectClass)
  {
    objectClass = pObjectClass;
  }

  @SuppressWarnings("unchecked")
  @Override
  public  Codec get(final Class pObjectClass, final CodecRegistry registry)
  {
    if (AbstractStorableObject.class.isAssignableFrom(pObjectClass))
      return (Codec) new CustomDocumentCodec<>(objectClass);
    return null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy