DATACMNS-1252 - Improved Vavr collection handling to convert between collection types.

If a query method now uses e.g. a Vavr Set as return type, we now also use a potential source List as input for the LinkedHashSet, even if that changes the characteristics (duplicate policy etc.) of the result. This is consistent with our general handling of collections as we're using a Spring ConversionService for collection mapping anyway.

In general the new conversion algorithm is driven by the expected target type first:

- i.v.c.Seq -> i.v.c.List
- i.v.c.Set -> i.v.c.LinkedHashSet
- i.v.c.Map -> i.v.c.LinkedHashMap

If none of the declared types is assignable we fall back to the previous algorithm choosing an implementation as close as possible to the original source value:

- j.u.List -> i.v.c.List
- j.u.Set  -> i.v.c.LinkedHashSet
- j.u.Map  -> i.v.c.LinkedHashMap

Removed some obsolete full qualifications of types.
This commit is contained in:
Oliver Gierke
2018-02-02 15:57:28 +01:00
parent 24a9493fa6
commit d5f57f2e59
2 changed files with 30 additions and 4 deletions

View File

@@ -338,4 +338,13 @@ public class QueryExecutionConvertersUnitTests {
Set<Class<?>> allowedPageableTypes = QueryExecutionConverters.getAllowedPageableTypes();
assertThat(allowedPageableTypes).contains(io.vavr.collection.Seq.class);
}
@Test // DATAJPA-1258
public void convertsJavaListsToVavrSet() {
List<String> source = Collections.singletonList("foo");
assertThat(conversionService.convert(source, io.vavr.collection.Set.class)) //
.isInstanceOf(io.vavr.collection.Set.class);
}
}