DATACMNS-1165 - Added support for Streamable as repository return type.
We now allow users to use our own Streamable interface as query method return types to easily invoke ….stream() on everything that returns an Iterable using non-parallel streaming by default.
This commit is contained in:
@@ -257,6 +257,7 @@ public abstract class QueryExecutionConverters {
|
||||
}
|
||||
|
||||
conversionService.addConverter(new NullableWrapperToFutureConverter(conversionService));
|
||||
conversionService.addConverter(IterableToStreamableConverter.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -697,6 +698,21 @@ public abstract class QueryExecutionConverters {
|
||||
}
|
||||
}
|
||||
|
||||
private static enum IterableToStreamableConverter implements Converter<Iterable<?>, Streamable<?>> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
|
||||
*/
|
||||
@Nonnull
|
||||
@Override
|
||||
public Streamable<?> convert(Iterable<?> source) {
|
||||
return Streamable.of(source);
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public static class WrapperType {
|
||||
|
||||
Reference in New Issue
Block a user