@@ -2754,31 +2754,26 @@ interface DocumentCallback<T> {
2754
2754
* @author Oliver Gierke
2755
2755
* @author Christoph Strobl
2756
2756
*/
2757
+ @ RequiredArgsConstructor
2757
2758
private class ReadDocumentCallback <T > implements DocumentCallback <T > {
2758
2759
2759
- private final EntityReader <? super T , Bson > reader ;
2760
- private final Class <T > type ;
2760
+ private final @ NonNull EntityReader <? super T , Bson > reader ;
2761
+ private final @ NonNull Class <T > type ;
2761
2762
private final String collectionName ;
2762
2763
2763
- public ReadDocumentCallback (EntityReader <? super T , Bson > reader , Class <T > type , String collectionName ) {
2764
-
2765
- Assert .notNull (reader , "EntityReader must not be null!" );
2766
- Assert .notNull (type , "Entity type must not be null!" );
2767
-
2768
- this .reader = reader ;
2769
- this .type = type ;
2770
- this .collectionName = collectionName ;
2771
- }
2772
-
2773
2764
@ Nullable
2774
- public T doWith (Document object ) {
2765
+ public T doWith (@ Nullable Document object ) {
2766
+
2775
2767
if (null != object ) {
2776
2768
maybeEmitEvent (new AfterLoadEvent <T >(object , type , collectionName ));
2777
2769
}
2770
+
2778
2771
T source = reader .read (type , object );
2772
+
2779
2773
if (null != source ) {
2780
2774
maybeEmitEvent (new AfterConvertEvent <T >(object , source , collectionName ));
2781
2775
}
2776
+
2782
2777
return source ;
2783
2778
}
2784
2779
}
@@ -2821,7 +2816,7 @@ public T doWith(@Nullable Document object) {
2821
2816
Object source = reader .read (typeToRead , object );
2822
2817
Object result = targetType .isInterface () ? projectionFactory .createProjection (targetType , source ) : source ;
2823
2818
2824
- if (result != null ) {
2819
+ if (null != result ) {
2825
2820
maybeEmitEvent (new AfterConvertEvent <>(object , result , collectionName ));
2826
2821
}
2827
2822
@@ -2974,7 +2969,7 @@ public GeoResult<T> doWith(@Nullable Document object) {
2974
2969
2975
2970
T doWith = delegate .doWith (content );
2976
2971
2977
- return new GeoResult <T >(doWith , new Distance (distance , metric ));
2972
+ return new GeoResult <>(doWith , new Distance (distance , metric ));
2978
2973
}
2979
2974
}
2980
2975
0 commit comments