2626import java .util .concurrent .CompletableFuture ;
2727import java .util .concurrent .ConcurrentHashMap ;
2828import java .util .concurrent .Future ;
29+ import java .util .function .Function ;
2930import java .util .stream .Stream ;
3031
3132import org .springframework .core .convert .ConversionService ;
3839import org .springframework .data .domain .Page ;
3940import org .springframework .data .domain .Slice ;
4041import org .springframework .data .geo .GeoResults ;
42+ import org .springframework .data .util .CustomCollections ;
4143import org .springframework .data .util .NullableWrapper ;
4244import org .springframework .data .util .NullableWrapperConverters ;
4345import org .springframework .data .util .StreamUtils ;
4446import org .springframework .data .util .Streamable ;
4547import org .springframework .data .util .TypeInformation ;
46- import org .springframework .data . util . VavrCollectionConverters ;
48+ import org .springframework .lang . NonNull ;
4749import org .springframework .lang .Nullable ;
4850import org .springframework .scheduling .annotation .AsyncResult ;
4951import org .springframework .util .Assert ;
@@ -80,7 +82,7 @@ public abstract class QueryExecutionConverters {
8082
8183 private static final Set <WrapperType > WRAPPER_TYPES = new HashSet <>();
8284 private static final Set <WrapperType > UNWRAPPER_TYPES = new HashSet <WrapperType >();
83- private static final Set <Converter <Object , Object >> UNWRAPPERS = new HashSet <>();
85+ private static final Set <Function <Object , Object >> UNWRAPPERS = new HashSet <>();
8486 private static final Set <Class <?>> ALLOWED_PAGEABLE_TYPES = new HashSet <>();
8587 private static final Map <Class <?>, ExecutionAdapter > EXECUTION_ADAPTER = new HashMap <>();
8688 private static final Map <Class <?>, Boolean > supportsCache = new ConcurrentReferenceHashMap <>();
@@ -98,16 +100,19 @@ public abstract class QueryExecutionConverters {
98100
99101 WRAPPER_TYPES .add (NullableWrapperToCompletableFutureConverter .getWrapperType ());
100102
101- if (VAVR_PRESENT ) {
103+ UNWRAPPERS .addAll (CustomCollections .getUnwrappers ());
104+
105+ CustomCollections .getCustomTypes ().stream ()
106+ .map (WrapperType ::multiValue )
107+ .forEach (WRAPPER_TYPES ::add );
102108
103- WRAPPER_TYPES .add (VavrTraversableUnwrapper .INSTANCE .getWrapperType ());
104- UNWRAPPERS .add (VavrTraversableUnwrapper .INSTANCE );
109+ CustomCollections .getPaginationReturnTypes ().forEach (ALLOWED_PAGEABLE_TYPES ::add );
110+
111+ if (VAVR_PRESENT ) {
105112
106113 // Try support
107114 WRAPPER_TYPES .add (WrapperType .singleValue (io .vavr .control .Try .class ));
108115 EXECUTION_ADAPTER .put (io .vavr .control .Try .class , it -> io .vavr .control .Try .of (it ::get ));
109-
110- ALLOWED_PAGEABLE_TYPES .add (io .vavr .collection .Seq .class );
111116 }
112117 }
113118
@@ -195,10 +200,7 @@ public static void registerConvertersIn(ConfigurableConversionService conversion
195200 conversionService .removeConvertible (Collection .class , Object .class );
196201
197202 NullableWrapperConverters .registerConvertersIn (conversionService );
198-
199- if (VAVR_PRESENT ) {
200- conversionService .addConverter (VavrCollectionConverters .FromJavaConverter .INSTANCE );
201- }
203+ CustomCollections .registerConvertersIn (conversionService );
202204
203205 conversionService .addConverter (new NullableWrapperToCompletableFutureConverter ());
204206 conversionService .addConverter (new NullableWrapperToFutureConverter ());
@@ -220,9 +222,9 @@ public static Object unwrap(@Nullable Object source) {
220222 return source ;
221223 }
222224
223- for (Converter <Object , Object > converter : UNWRAPPERS ) {
225+ for (Function <Object , Object > converter : UNWRAPPERS ) {
224226
225- Object result = converter .convert (source );
227+ Object result = converter .apply (source );
226228
227229 if (result != source ) {
228230 return result ;
@@ -382,36 +384,6 @@ static WrapperType getWrapperType() {
382384 }
383385 }
384386
385- /**
386- * Converter to unwrap Vavr {@link io.vavr.collection.Traversable} instances.
387- *
388- * @author Oliver Gierke
389- * @since 2.0
390- */
391- private enum VavrTraversableUnwrapper implements Converter <Object , Object > {
392-
393- INSTANCE ;
394-
395- private static final TypeDescriptor OBJECT_DESCRIPTOR = TypeDescriptor .valueOf (Object .class );
396-
397- @ Nullable
398- @ Override
399- @ SuppressWarnings ("null" )
400- public Object convert (Object source ) {
401-
402- if (source instanceof io .vavr .collection .Traversable ) {
403- return VavrCollectionConverters .ToJavaConverter .INSTANCE //
404- .convert (source , TypeDescriptor .forObject (source ), OBJECT_DESCRIPTOR );
405- }
406-
407- return source ;
408- }
409-
410- public WrapperType getWrapperType () {
411- return WrapperType .multiValue (io .vavr .collection .Traversable .class );
412- }
413- }
414-
415387 private static class IterableToStreamableConverter implements ConditionalGenericConverter {
416388
417389 private static final TypeDescriptor STREAMABLE = TypeDescriptor .valueOf (Streamable .class );
@@ -477,7 +449,7 @@ public Cardinality getCardinality() {
477449 }
478450
479451 @ Override
480- public boolean equals (Object o ) {
452+ public boolean equals (@ Nullable Object o ) {
481453
482454 if (this == o ) {
483455 return true ;
0 commit comments