Package dev.morphia.geo
Class GeometryShapeConverter<T>
- java.lang.Object
-
- dev.morphia.geo.GeometryShapeConverter<T>
-
- Type Parameters:
T
- the type
- All Implemented Interfaces:
org.bson.codecs.Codec<T>
,org.bson.codecs.Decoder<T>
,org.bson.codecs.Encoder<T>
public class GeometryShapeConverter<T> extends Object implements org.bson.codecs.Codec<T>
Converter that understands most Geometry instances are effectively just lists of either other geometry objects or double coordinates. Recursively encodes and decodes Geometry objects, but needs to be instantiated with a List of GeometryFactory instances that represented the hierarchy of Geometries that make up the required Geometry object. Overridden by subclasses to define exact behaviour for specific Geometry concrete classes.
-
-
Constructor Summary
Constructors Constructor Description GeometryShapeConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
Decodes a BSON value from the given reader into an instance of the type parameterT
.void
encode(org.bson.BsonWriter writer, T value, org.bson.codecs.EncoderContext encoderContext)
Encode an instance of the type parameterT
into a BSON value.Class<T>
getEncoderClass()
Returns the Class instance that this encodes.
-
-
-
Method Detail
-
decode
public T decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext)
Description copied from interface:org.bson.codecs.Decoder
Decodes a BSON value from the given reader into an instance of the type parameterT
.- Specified by:
decode
in interfaceorg.bson.codecs.Decoder<T>
- Parameters:
reader
- the BSON readerdecoderContext
- the decoder context- Returns:
- an instance of the type parameter
T
.
-
encode
public void encode(org.bson.BsonWriter writer, T value, org.bson.codecs.EncoderContext encoderContext)
Description copied from interface:org.bson.codecs.Encoder
Encode an instance of the type parameterT
into a BSON value.- Specified by:
encode
in interfaceorg.bson.codecs.Encoder<T>
- Parameters:
writer
- the BSON writer to encode intovalue
- the value to encodeencoderContext
- the encoder context
-
getEncoderClass
public Class<T> getEncoderClass()
Description copied from interface:org.bson.codecs.Encoder
Returns the Class instance that this encodes. This is necessary because Java does not reify generic types.- Specified by:
getEncoderClass
in interfaceorg.bson.codecs.Encoder<T>
- Returns:
- the Class instance that this encodes.
-
-