use of io.micronaut.data.model.Slice in project micronaut-data by micronaut-projects.
the class DefaultFindSliceReactiveInterceptor method intercept.
@Override
public Object intercept(RepositoryMethodKey methodKey, MethodInvocationContext<Object, Object> context) {
if (context.hasAnnotation(Query.class)) {
PreparedQuery<Object, Object> preparedQuery = (PreparedQuery<Object, Object>) prepareQuery(methodKey, context);
Pageable pageable = preparedQuery.getPageable();
Mono<Slice<Object>> publisher = Flux.from(reactiveOperations.findAll(preparedQuery)).collectList().map(objects -> Slice.of(objects, pageable));
return Publishers.convertPublisher(publisher, context.getReturnType().getType());
} else {
PagedQuery<Object> pagedQuery = getPagedQuery(context);
Mono<? extends Slice<?>> result = Flux.from(reactiveOperations.findAll(pagedQuery)).collectList().map(objects -> Slice.of(objects, pagedQuery.getPageable()));
return Publishers.convertPublisher(result, context.getReturnType().getType());
}
}
Aggregations