@@ -311,7 +311,7 @@ public <T> Mono<T> save(T entity, IndexCoordinates index) {
311
311
Assert .notNull (entity , "Entity must not be null!" );
312
312
Assert .notNull (index , "index must not be null" );
313
313
314
- return maybeCallBeforeConvert (entity , index )
314
+ return maybeCallbackBeforeConvert (entity , index )
315
315
.flatMap (entityAfterBeforeConversionCallback -> doIndex (entityAfterBeforeConversionCallback , index )) //
316
316
.map (it -> {
317
317
T savedEntity = it .getT1 ();
@@ -321,7 +321,7 @@ public <T> Mono<T> save(T entity, IndexCoordinates index) {
321
321
indexResponseMetaData .seqNo (), //
322
322
indexResponseMetaData .primaryTerm (), //
323
323
indexResponseMetaData .version ()));
324
- }).flatMap (saved -> maybeCallAfterSave (saved , index ));
324
+ }).flatMap (saved -> maybeCallbackAfterSave (saved , index ));
325
325
}
326
326
327
327
abstract protected <T > Mono <Tuple2 <T , IndexResponseMetaData >> doIndex (T entity , IndexCoordinates index );
@@ -493,7 +493,7 @@ public Mono<Boolean> closePointInTime(String pit) {
493
493
494
494
// region callbacks
495
495
496
- protected <T > Mono <T > maybeCallBeforeConvert (T entity , IndexCoordinates index ) {
496
+ protected <T > Mono <T > maybeCallbackBeforeConvert (T entity , IndexCoordinates index ) {
497
497
498
498
if (null != entityCallbacks ) {
499
499
return entityCallbacks .callback (ReactiveBeforeConvertCallback .class , entity , index );
@@ -502,7 +502,7 @@ protected <T> Mono<T> maybeCallBeforeConvert(T entity, IndexCoordinates index) {
502
502
return Mono .just (entity );
503
503
}
504
504
505
- protected <T > Mono <T > maybeCallAfterSave (T entity , IndexCoordinates index ) {
505
+ protected <T > Mono <T > maybeCallbackAfterSave (T entity , IndexCoordinates index ) {
506
506
507
507
if (null != entityCallbacks ) {
508
508
return entityCallbacks .callback (ReactiveAfterSaveCallback .class , entity , index );
@@ -511,7 +511,7 @@ protected <T> Mono<T> maybeCallAfterSave(T entity, IndexCoordinates index) {
511
511
return Mono .just (entity );
512
512
}
513
513
514
- protected <T > Mono <T > maybeCallAfterConvert (T entity , Document document , IndexCoordinates index ) {
514
+ protected <T > Mono <T > maybeCallbackAfterConvert (T entity , Document document , IndexCoordinates index ) {
515
515
516
516
if (null != entityCallbacks ) {
517
517
return entityCallbacks .callback (ReactiveAfterConvertCallback .class , entity , document , index );
@@ -528,8 +528,19 @@ protected <T> Mono<Document> maybeCallbackAfterLoad(Document document, Class<T>
528
528
return Mono .just (document );
529
529
}
530
530
531
+ /**
532
+ * Callback to convert {@link Document} into an entity of type T
533
+ *
534
+ * @param <T> the entity type
535
+ */
531
536
protected interface DocumentCallback <T > {
532
537
538
+ /**
539
+ * Convert a document into an entity
540
+ *
541
+ * @param document the document to convert
542
+ * @return a Mono of the entity
543
+ */
533
544
@ NonNull
534
545
Mono <T > toEntity (@ Nullable Document document );
535
546
}
@@ -566,16 +577,30 @@ public Mono<T> toEntity(@Nullable Document document) {
566
577
documentAfterLoad .hasVersion () ? documentAfterLoad .getVersion () : null ); //
567
578
entity = updateIndexedObject (entity , indexedObjectInformation );
568
579
569
- return maybeCallAfterConvert (entity , documentAfterLoad , index );
580
+ return maybeCallbackAfterConvert (entity , documentAfterLoad , index );
570
581
});
571
582
}
572
583
}
573
584
585
+ /**
586
+ * Callback to convert a {@link SearchDocument} into different other classes
587
+ * @param <T> the entity type
588
+ */
574
589
protected interface SearchDocumentCallback <T > {
575
590
576
- Mono <T > toEntity (SearchDocument response );
577
-
578
- Mono <SearchHit <T >> toSearchHit (SearchDocument response );
591
+ /**
592
+ * converts a {@link SearchDocument} to an entity
593
+ * @param searchDocument
594
+ * @return the entity in a MOno
595
+ */
596
+ Mono <T > toEntity (SearchDocument searchDocument );
597
+
598
+ /**
599
+ * converts a {@link SearchDocument} into a SearchHit
600
+ * @param searchDocument
601
+ * @return
602
+ */
603
+ Mono <SearchHit <T >> toSearchHit (SearchDocument searchDocument );
579
604
}
580
605
581
606
protected class ReadSearchDocumentCallback <T > implements SearchDocumentCallback <T > {
0 commit comments