Class ReferenceCodec
- java.lang.Object
-
- dev.morphia.mapping.codec.BaseReferenceCodec<Object>
-
- dev.morphia.mapping.codec.references.ReferenceCodec
-
- All Implemented Interfaces:
PropertyHandler
,org.bson.codecs.Codec<Object>
,org.bson.codecs.Decoder<Object>
,org.bson.codecs.Encoder<Object>
public class ReferenceCodec extends BaseReferenceCodec<Object> implements PropertyHandler
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 ReferenceCodec(Datastore datastore, PropertyModel propertyModel)
Creates a codec
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
Object
encode(Object value)
Encodes the valuevoid
encode(org.bson.BsonWriter writer, Object instance, org.bson.codecs.EncoderContext encoderContext)
static Object
encodeId(Mapper mapper, Datastore datastore, Object value, PropertyModel model)
Encodes a valuestatic Object
encodeId(Mapper mapper, Object value, EntityModel model)
Encodes a valueClass
getEncoderClass()
static Object
processId(Object decode, Mapper mapper, org.bson.codecs.DecoderContext decoderContext)
Decodes an ID value-
Methods inherited from class dev.morphia.mapping.codec.BaseReferenceCodec
getDatastore, getEntityModelForField, getPropertyModel, getReferenceAnnotation, getTypeData
-
-
-
-
Constructor Detail
-
ReferenceCodec
public ReferenceCodec(Datastore datastore, PropertyModel propertyModel)
Creates a codec- Parameters:
datastore
- the datastore to usepropertyModel
- the reference property
-
-
Method Detail
-
encodeId
@Nullable public static Object encodeId(Mapper mapper, Datastore datastore, Object value, PropertyModel model)
Encodes a value- Parameters:
mapper
- the mapper to usedatastore
- the datastore to usevalue
- the value to encodemodel
- the mapped class of the field type- Returns:
- the encoded value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
encodeId
@Nullable public static Object encodeId(Mapper mapper, Object value, EntityModel model)
Encodes a value- Parameters:
mapper
- the mapper to usevalue
- the value to encodemodel
- the mapped class of the field type- Returns:
- the encoded value
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
processId
@NonNull public static Object processId(Object decode, Mapper mapper, org.bson.codecs.DecoderContext decoderContext)
Decodes an ID value- Parameters:
decode
- the value to decodemapper
- the mapper to usedecoderContext
- the decoder context- Returns:
- the decoded value
-
decode
@Nullable public Object decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
- Specified by:
decode
in interfaceorg.bson.codecs.Decoder<Object>
-
encode
public void encode(org.bson.BsonWriter writer, Object instance, org.bson.codecs.EncoderContext encoderContext)
- Specified by:
encode
in interfaceorg.bson.codecs.Encoder<Object>
-
getEncoderClass
public Class getEncoderClass()
- Specified by:
getEncoderClass
in interfaceorg.bson.codecs.Encoder<Object>
-
encode
public Object encode(@Nullable Object value)
Description copied from interface:PropertyHandler
Encodes the value- Specified by:
encode
in interfacePropertyHandler
- Parameters:
value
- the value- Returns:
- the encoded value
-
-