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:
Oliver Gierke
2017-09-20 16:31:29 +02:00
parent 1a199847cd
commit e7ae4a8bb8
2 changed files with 31 additions and 0 deletions

View File

@@ -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 {