@ -65,7 +65,7 @@ import com.mongodb.Function;
@@ -65,7 +65,7 @@ import com.mongodb.Function;
@SuppressWarnings ( "ConstantConditions" )
abstract class GeoConverters {
private final static Map < String , Function < Document , GeoJson < ? > > > converters ;
private final static Map < String , Function < Document , @Nullable GeoJson < ? > > > converters ;
static {
@ -127,15 +127,15 @@ abstract class GeoConverters {
@@ -127,15 +127,15 @@ abstract class GeoConverters {
* @since 1 . 5
* /
@ReadingConverter
enum DocumentToPointConverter implements Converter < Document , Point > {
enum DocumentToPointConverter implements Converter < Document , @Nullable Point > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable Point convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public Point convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -155,6 +155,7 @@ abstract class GeoConverters {
@@ -155,6 +155,7 @@ abstract class GeoConverters {
* @author Thomas Darimont
* @since 1 . 5
* /
@SuppressWarnings ( "NullAway" )
enum PointToDocumentConverter implements Converter < Point , Document > {
INSTANCE ;
@ -173,6 +174,7 @@ abstract class GeoConverters {
@@ -173,6 +174,7 @@ abstract class GeoConverters {
* @since 1 . 5
* /
@WritingConverter
@SuppressWarnings ( "NullAway" )
enum BoxToDocumentConverter implements Converter < Box , Document > {
INSTANCE ;
@ -199,21 +201,25 @@ abstract class GeoConverters {
@@ -199,21 +201,25 @@ abstract class GeoConverters {
* @since 1 . 5
* /
@ReadingConverter
enum DocumentToBoxConverter implements Converter < Document , Box > {
enum DocumentToBoxConverter implements Converter < Document , @Nullable Box > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null" )
@SuppressWarnings ( "NullAway" )
public @Nullable Box convert ( @Nullable Document source ) {
public Box convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
Point first = DocumentToPointConverter . INSTANCE . convert ( ( Document ) source . get ( "first" ) ) ;
Point second = DocumentToPointConverter . INSTANCE . convert ( ( Document ) source . get ( "second" ) ) ;
Document firstDoc = ( Document ) source . get ( "first" ) ;
Document secondDoc = ( Document ) source . get ( "second" ) ;
Assert . notNull ( firstDoc , "first must not be null" ) ;
Assert . notNull ( secondDoc , "second must not be null" ) ;
Point first = DocumentToPointConverter . INSTANCE . convert ( firstDoc ) ;
Point second = DocumentToPointConverter . INSTANCE . convert ( secondDoc ) ;
return new Box ( first , second ) ;
}
@ -225,6 +231,7 @@ abstract class GeoConverters {
@@ -225,6 +231,7 @@ abstract class GeoConverters {
* @author Thomas Darimont
* @since 1 . 5
* /
@SuppressWarnings ( "NullAway" )
enum CircleToDocumentConverter implements Converter < Circle , Document > {
INSTANCE ;
@ -252,15 +259,15 @@ abstract class GeoConverters {
@@ -252,15 +259,15 @@ abstract class GeoConverters {
* @since 1 . 5
* /
@ReadingConverter
enum DocumentToCircleConverter implements Converter < Document , Circle > {
enum DocumentToCircleConverter implements Converter < Document , @Nullable Circle > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable Circle convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public Circle convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -290,6 +297,7 @@ abstract class GeoConverters {
@@ -290,6 +297,7 @@ abstract class GeoConverters {
* @author Thomas Darimont
* @since 1 . 5
* /
@SuppressWarnings ( "NullAway" )
enum SphereToDocumentConverter implements Converter < Sphere , Document > {
INSTANCE ;
@ -317,15 +325,15 @@ abstract class GeoConverters {
@@ -317,15 +325,15 @@ abstract class GeoConverters {
* @since 1 . 5
* /
@ReadingConverter
enum DocumentToSphereConverter implements Converter < Document , Sphere > {
enum DocumentToSphereConverter implements Converter < Document , @Nullable Sphere > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable Sphere convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public Sphere convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -355,6 +363,7 @@ abstract class GeoConverters {
@@ -355,6 +363,7 @@ abstract class GeoConverters {
* @author Thomas Darimont
* @since 1 . 5
* /
@SuppressWarnings ( "NullAway" )
enum PolygonToDocumentConverter implements Converter < Polygon , Document > {
INSTANCE ;
@ -387,16 +396,15 @@ abstract class GeoConverters {
@@ -387,16 +396,15 @@ abstract class GeoConverters {
* @since 1 . 5
* /
@ReadingConverter
enum DocumentToPolygonConverter implements Converter < Document , Polygon > {
enum DocumentToPolygonConverter implements Converter < Document , @Nullable Polygon > {
INSTANCE ;
@Override
@SuppressWarnings ( { "unchecked" } )
@Contract ( "null -> null; !null -> !null" )
public @Nullable Polygon convert ( @Nullable Document source ) {
@SuppressWarnings ( { "unchecked" , "NullAway" } )
public Polygon convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -420,6 +428,7 @@ abstract class GeoConverters {
@@ -420,6 +428,7 @@ abstract class GeoConverters {
* @author Thomas Darimont
* @since 1 . 5
* /
@SuppressWarnings ( "NullAway" )
enum GeoCommandToDocumentConverter implements Converter < GeoCommand , Document > {
INSTANCE ;
@ -473,6 +482,7 @@ abstract class GeoConverters {
@@ -473,6 +482,7 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
@SuppressWarnings ( "NullAway" )
enum GeoJsonToDocumentConverter implements Converter < GeoJson < ? > , Document > {
INSTANCE ;
@ -561,16 +571,15 @@ abstract class GeoConverters {
@@ -561,16 +571,15 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
enum DocumentToGeoJsonPointConverter implements Converter < Document , GeoJsonPoint > {
enum DocumentToGeoJsonPointConverter implements Converter < Document , @Nullable GeoJsonPoint > {
INSTANCE ;
@Override
@SuppressWarnings ( "unchecked" )
@Contract ( "null -> null; !null -> !null" )
public @Nullable GeoJsonPoint convert ( @Nullable Document source ) {
@SuppressWarnings ( { "unchecked" , "NullAway" } )
public GeoJsonPoint convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -589,15 +598,15 @@ abstract class GeoConverters {
@@ -589,15 +598,15 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
enum DocumentToGeoJsonPolygonConverter implements Converter < Document , GeoJsonPolygon > {
enum DocumentToGeoJsonPolygonConverter implements Converter < Document , @Nullable GeoJsonPolygon > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable GeoJsonPolygon convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public GeoJsonPolygon convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -612,15 +621,15 @@ abstract class GeoConverters {
@@ -612,15 +621,15 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
enum DocumentToGeoJsonMultiPolygonConverter implements Converter < Document , GeoJsonMultiPolygon > {
enum DocumentToGeoJsonMultiPolygonConverter implements Converter < Document , @Nullable GeoJsonMultiPolygon > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable GeoJsonMultiPolygon convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public GeoJsonMultiPolygon convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -643,15 +652,15 @@ abstract class GeoConverters {
@@ -643,15 +652,15 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
enum DocumentToGeoJsonLineStringConverter implements Converter < Document , GeoJsonLineString > {
enum DocumentToGeoJsonLineStringConverter implements Converter < Document , @Nullable GeoJsonLineString > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable GeoJsonLineString convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public GeoJsonLineString convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -668,15 +677,15 @@ abstract class GeoConverters {
@@ -668,15 +677,15 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
enum DocumentToGeoJsonMultiPointConverter implements Converter < Document , GeoJsonMultiPoint > {
enum DocumentToGeoJsonMultiPointConverter implements Converter < Document , @Nullable GeoJsonMultiPoint > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable GeoJsonMultiPoint convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public GeoJsonMultiPoint convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -693,15 +702,15 @@ abstract class GeoConverters {
@@ -693,15 +702,15 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
enum DocumentToGeoJsonMultiLineStringConverter implements Converter < Document , GeoJsonMultiLineString > {
enum DocumentToGeoJsonMultiLineStringConverter implements Converter < Document , @Nullable GeoJsonMultiLineString > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable GeoJsonMultiLineString convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public GeoJsonMultiLineString convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -725,15 +734,15 @@ abstract class GeoConverters {
@@ -725,15 +734,15 @@ abstract class GeoConverters {
* @author Christoph Strobl
* @since 1 . 7
* /
enum DocumentToGeoJsonGeometryCollectionConverter implements Converter < Document , GeoJsonGeometryCollection > {
enum DocumentToGeoJsonGeometryCollectionConverter implements Converter < Document , @Nullable GeoJsonGeometryCollection > {
INSTANCE ;
@Override
@Contract ( "null -> null; !null -> !null " )
public @Nullable GeoJsonGeometryCollection convert ( @Nullable Document source ) {
@SuppressWarnings ( "NullAway " )
public GeoJsonGeometryCollection convert ( Document source ) {
if ( source = = null ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
@ -808,11 +817,17 @@ abstract class GeoConverters {
@@ -808,11 +817,17 @@ abstract class GeoConverters {
* @author Christoph Strobl
* /
@ReadingConverter
enum DocumentToGeoJsonConverter implements Converter < Document , GeoJson < ? > > {
enum DocumentToGeoJsonConverter implements Converter < Document , @Nullable GeoJson < ? > > {
INSTANCE ;
@Override
@SuppressWarnings ( "NullAway" )
public GeoJson < ? > convert ( Document source ) {
if ( ObjectUtils . isEmpty ( source ) ) {
return null ;
}
return toGenericGeoJson ( source ) ;
}
}