Package dev.morphia.geo
Class GeometryShapeConverter
- java.lang.Object
-
- dev.morphia.converters.TypeConverter
-
- dev.morphia.geo.GeometryShapeConverter
-
- All Implemented Interfaces:
SimpleValueConverter
- Direct Known Subclasses:
GeometryShapeConverter.LineStringConverter
,GeometryShapeConverter.MultiLineStringConverter
,GeometryShapeConverter.MultiPointConverter
,GeometryShapeConverter.MultiPolygonConverter
,GeometryShapeConverter.PointConverter
,GeometryShapeConverter.PolygonConverter
public class GeometryShapeConverter extends TypeConverter implements SimpleValueConverter
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GeometryShapeConverter.LineStringConverter
Defines a new LineStringConverter.static class
GeometryShapeConverter.MultiLineStringConverter
Defines a new MultiLineStringConverter.static class
GeometryShapeConverter.MultiPointConverter
Defines a new MultiPointConverter.static class
GeometryShapeConverter.MultiPolygonConverter
Extends and therefore configures GeometryShapeConverter to provide the specific configuration for converting MultiPolygon objects to and from MongoDB representations of the GeoJson.static class
GeometryShapeConverter.PointConverter
Defines a new PointConverter.static class
GeometryShapeConverter.PolygonConverter
Defines a new PolygonConverter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Geometry
decode(java.lang.Class<?> targetClass, java.lang.Object fromDBObject, MappedField optionalExtraInfo)
decode theDBObject
and provide the corresponding java (type-safe) object
NOTE: optionalExtraInfo might be nulljava.lang.Object
encode(java.lang.Object value, MappedField optionalExtraInfo)
encode the (type-safe) java object into the correspondingDBObject
-
Methods inherited from class dev.morphia.converters.TypeConverter
decode, encode, equals, getMapper, getSupportTypes, hashCode, isSupported, oneOf, oneOfClasses, setMapper, setSupportedTypes, setSupportTypes
-
-
-
-
Method Detail
-
decode
public Geometry decode(java.lang.Class<?> targetClass, java.lang.Object fromDBObject, MappedField optionalExtraInfo)
Description copied from class:TypeConverter
decode theDBObject
and provide the corresponding java (type-safe) object
NOTE: optionalExtraInfo might be null- Specified by:
decode
in classTypeConverter
- Parameters:
targetClass
- the class to create and populatefromDBObject
- the DBObject to use when populating the new instanceoptionalExtraInfo
- the MappedField that contains the metadata useful for decoding- Returns:
- the new instance
-
encode
public java.lang.Object encode(java.lang.Object value, MappedField optionalExtraInfo)
Description copied from class:TypeConverter
encode the (type-safe) java object into the correspondingDBObject
- Overrides:
encode
in classTypeConverter
- Parameters:
value
- The object to encodeoptionalExtraInfo
- the MappedField that contains the metadata useful for decoding- Returns:
- the encoded version of the object
-
-