Example usage for org.springframework.data.domain Page empty

List of usage examples for org.springframework.data.domain Page empty

Introduction

In this page you can find the example usage for org.springframework.data.domain Page empty.

Prototype

static <T> Page<T> empty() 

Source Link

Document

Creates a new empty Page .

Usage

From source file:aiai.ai.launchpad.experiment.ExperimentService.java

Slice<Task> findTasks(Pageable pageable, Experiment experiment, ExperimentFeature feature, String[] params) {
    if (experiment == null || feature == null) {
        return Page.empty();
    } else {//from  w  w w. j  a  v a  2 s .  c o m
        if (isEmpty(params)) {
            if (true)
                throw new IllegalStateException("Not implemented yet");
            return null;
            //                return taskRepository.findByIsCompletedIsTrueAndFeatureId(pageable, feature.getId());
        } else {
            List<Task> selected = findTaskWithFilter(experiment, feature.getId(), params);
            List<Task> subList = selected.subList((int) pageable.getOffset(),
                    (int) Math.min(selected.size(), pageable.getOffset() + pageable.getPageSize()));
            //noinspection UnnecessaryLocalVariable
            final PageImpl<Task> page = new PageImpl<>(subList, pageable, selected.size());
            return page;

        }
    }
}