Package dev.morphia.mapping.codec.pojo
Class MorphiaCodec<T>
- java.lang.Object
-
- dev.morphia.mapping.codec.pojo.MorphiaCodec<T>
-
- Type Parameters:
T
- the entity type
- All Implemented Interfaces:
org.bson.codecs.Codec<T>
,org.bson.codecs.CollectibleCodec<T>
,org.bson.codecs.Decoder<T>
,org.bson.codecs.Encoder<T>
public class MorphiaCodec<T> extends Object implements org.bson.codecs.CollectibleCodec<T>
the codec used by Morphia- Since:
- 2.0
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
-
Constructor Summary
Constructors Constructor Description MorphiaCodec(Datastore datastore, EntityModel model, List<org.bson.codecs.pojo.PropertyCodecProvider> propertyCodecProviders, DiscriminatorLookup discriminatorLookup, org.bson.codecs.configuration.CodecRegistry registry)
Creates a new codec
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
boolean
documentHasId(Object entity)
void
encode(org.bson.BsonWriter writer, Object value, org.bson.codecs.EncoderContext encoderContext)
Object
generateIdIfAbsentFromDocument(Object entity)
protected EntityDecoder
getDecoder()
org.bson.BsonValue
getDocumentId(Object document)
Class
getEncoderClass()
EntityModel
getEntityModel()
Mapper
getMapper()
-
-
-
Constructor Detail
-
MorphiaCodec
public MorphiaCodec(Datastore datastore, EntityModel model, List<org.bson.codecs.pojo.PropertyCodecProvider> propertyCodecProviders, DiscriminatorLookup discriminatorLookup, org.bson.codecs.configuration.CodecRegistry registry)
Creates a new codec- Parameters:
datastore
- the datastoremodel
- the model backing this codecpropertyCodecProviders
- the codec provider for propertiesregistry
- the codec registry for lookupsdiscriminatorLookup
- the discriminator to type lookup
-
-
Method Detail
-
decode
public T decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
- Specified by:
decode
in interfaceorg.bson.codecs.Decoder<T>
-
documentHasId
public boolean documentHasId(Object entity)
- Specified by:
documentHasId
in interfaceorg.bson.codecs.CollectibleCodec<T>
-
getEntityModel
public EntityModel getEntityModel()
- Returns:
- the entity model backing this codec
-
getDecoder
protected EntityDecoder getDecoder()
-
encode
public void encode(org.bson.BsonWriter writer, Object value, org.bson.codecs.EncoderContext encoderContext)
- Specified by:
encode
in interfaceorg.bson.codecs.Encoder<T>
-
getEncoderClass
public Class getEncoderClass()
- Specified by:
getEncoderClass
in interfaceorg.bson.codecs.Encoder<T>
-
generateIdIfAbsentFromDocument
public Object generateIdIfAbsentFromDocument(Object entity)
- Specified by:
generateIdIfAbsentFromDocument
in interfaceorg.bson.codecs.CollectibleCodec<T>
-
getDocumentId
public org.bson.BsonValue getDocumentId(Object document)
- Specified by:
getDocumentId
in interfaceorg.bson.codecs.CollectibleCodec<T>
-
getMapper
public Mapper getMapper()
- Returns:
- the mapper being used
-
-