@@ -2771,31 +2771,26 @@ interface DocumentCallback<T> {
2771
2771
* @author Oliver Gierke
2772
2772
* @author Christoph Strobl
2773
2773
*/
2774
+ @ RequiredArgsConstructor
2774
2775
private class ReadDocumentCallback <T > implements DocumentCallback <T > {
2775
2776
2776
- private final EntityReader <? super T , Bson > reader ;
2777
- private final Class <T > type ;
2777
+ private final @ NonNull EntityReader <? super T , Bson > reader ;
2778
+ private final @ NonNull Class <T > type ;
2778
2779
private final String collectionName ;
2779
2780
2780
- public ReadDocumentCallback (EntityReader <? super T , Bson > reader , Class <T > type , String collectionName ) {
2781
-
2782
- Assert .notNull (reader , "EntityReader must not be null!" );
2783
- Assert .notNull (type , "Entity type must not be null!" );
2784
-
2785
- this .reader = reader ;
2786
- this .type = type ;
2787
- this .collectionName = collectionName ;
2788
- }
2789
-
2790
2781
@ Nullable
2791
- public T doWith (Document object ) {
2782
+ public T doWith (@ Nullable Document object ) {
2783
+
2792
2784
if (null != object ) {
2793
2785
maybeEmitEvent (new AfterLoadEvent <T >(object , type , collectionName ));
2794
2786
}
2787
+
2795
2788
T source = reader .read (type , object );
2789
+
2796
2790
if (null != source ) {
2797
2791
maybeEmitEvent (new AfterConvertEvent <T >(object , source , collectionName ));
2798
2792
}
2793
+
2799
2794
return source ;
2800
2795
}
2801
2796
}
@@ -2838,7 +2833,7 @@ public T doWith(@Nullable Document object) {
2838
2833
Object source = reader .read (typeToRead , object );
2839
2834
Object result = targetType .isInterface () ? projectionFactory .createProjection (targetType , source ) : source ;
2840
2835
2841
- if (result != null ) {
2836
+ if (null != result ) {
2842
2837
maybeEmitEvent (new AfterConvertEvent <>(object , result , collectionName ));
2843
2838
}
2844
2839
@@ -2991,7 +2986,7 @@ public GeoResult<T> doWith(@Nullable Document object) {
2991
2986
2992
2987
T doWith = delegate .doWith (content );
2993
2988
2994
- return new GeoResult <T >(doWith , new Distance (distance , metric ));
2989
+ return new GeoResult <>(doWith , new Distance (distance , metric ));
2995
2990
}
2996
2991
}
2997
2992
0 commit comments