当前位置: 首页>>代码示例>>Java>>正文


Java Pageable.getPageNumber方法代码示例

本文整理汇总了Java中org.springframework.data.domain.Pageable.getPageNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Pageable.getPageNumber方法的具体用法?Java Pageable.getPageNumber怎么用?Java Pageable.getPageNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.domain.Pageable的用法示例。


在下文中一共展示了Pageable.getPageNumber方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPageRequest

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * Create pageable request with default sort.
 *
 * @param page Page.
 * @param defaultSort Default sort object.
 * @param caseSensitiveSortProperties List of case sensitive properties or {@link #CASE_SENSITIVE_PROPERTIES} for
 *                                       all properties to be case sensitive.
 * @return Page object.
 */
public static PageRequest createPageRequest(Pageable page, Sort defaultSort,
											Collection<String> caseSensitiveSortProperties) {
	Sort sort = page.getSort();
	sort = sort == null ? defaultSort : sort.and(defaultSort);

	List<Sort.Order> ignoreCaseOrderList = Collections.emptyList();
	if (sort != null) {
		ignoreCaseOrderList = StreamUtils.createStreamFromIterator(sort.iterator())
				.map(order -> {
					if (caseSensitiveSortProperties == CASE_SENSITIVE_PROPERTIES ||
							caseSensitiveSortProperties.contains(order.getProperty())) {
						return order.ignoreCase();
					}
					return order;
				})
				.collect(Collectors.toList());
	}

	if (ignoreCaseOrderList.isEmpty()) {
		return new PageRequest(page.getPageNumber(), page.getPageSize());
	}
	return new PageRequest(page.getPageNumber(), page.getPageSize(), new Sort(ignoreCaseOrderList));
}
 
开发者ID:ATLANTBH,项目名称:owl,代码行数:33,代码来源:ServicesUtils.java

示例2: listHot

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * Retrieves hot medium elements from the cache and retrieves the object information from the database
 *
 * @param pageable pagination settings
 * @return list of medium elements
 */
@ApiOperation("Retrieves all Media elements by how \"hot\" they are")
@RequestMapping(value = "/Hot", method = RequestMethod.GET)
Page<Medium> listHot(final Pageable pageable) {
    final int page = pageable.getPageNumber();
    final int count = pageable.getPageSize();

    final RScoredSortedSet<String> set = redissonClient.getScoredSortedSet("HotMediaByScore");
    if (set.size() == 0) {
        retrieveHotToCache();
    }

    final Collection<ScoredEntry<String>> mediaCollection = set.entryRange(page * count, ((page + 1) * count) - 1);

    final List<Medium> mediaList = mediaCollection.stream()
            .map(entry -> mediumService.findOne(entry.getValue()))
            .filter(Optional::isPresent)
            .map(Optional::get)
            .filter(AuditedEntity::getActive)
            .collect(Collectors.toList());

    return new PageImpl<>(mediaList, pageable, set.size());
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:29,代码来源:MediumController.java

示例3: matchPageable

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
private Matcher<Pageable> matchPageable(int page, int size) {
    return new BaseMatcher<Pageable>() {

        @Override
        public void describeTo(Description description) {
            description.appendText("Pagable should have pageNumber ").appendValue(page).appendText(" and pageSize ").appendValue(size);
        }

        @Override
        public boolean matches(Object item) {
            if (item instanceof Pageable) {
                Pageable p = (Pageable) item;
                return p.getPageNumber() == page && p.getPageSize() == size;
            }
            return false;
        }
    };
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:19,代码来源:EmailControllerTest.java

示例4: getAllByPage

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * Handles a GET request by returning posts in a paginated format. Default page is 0, and default size = 20
 *
 * @param pageable the page and page size
 * @param filter only displays flagged posts if true, false by default
 * @return A Page with Post information
 */
@ApiOperation("Get all posts in a paginated format")
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Page<Post> getAllByPage(Pageable pageable,
                               @RequestParam(required = false, defaultValue = "false") Boolean filter) {
    Sort sort = new Sort(Sort.Direction.DESC, "publishedAt");
    Pageable sortedPageable = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), sort);

    if (filter) {
        BooleanExpression predecate = QPost.post.flagReasons.isNotEmpty();
        return postRepository.findAll(predecate, sortedPageable);
    }

    return postRepository.findAll(sortedPageable);
}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:22,代码来源:AdminPostController.java

示例5: getAllByPage

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * Handles a GET request by returning posts in a paginated format. Default page is 0, and default size = 20
 *
 * @param pageable         the page and page size
 * @param sourcesWhitelist optional list of requested sources
 * @return A Page with Post information
 */
@ApiOperation("Get all posts in a paginated format")
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public Page<Post> getAllByPage(Pageable pageable, @RequestParam(value = "whitelist", required = false)
    String[] sourcesWhitelist, @RequestParam(required = false, defaultValue = "") String query) {
    Sort sort = new Sort(Sort.Direction.DESC, "publishedAt");
    Pageable sortedPageable = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), sort);
    if (query.isEmpty() && sourcesWhitelist != null) {
        return postRepository.findAll(notHidden().and(isAllowed(sourcesWhitelist)), sortedPageable);
    } else if (query.isEmpty()) {
        return postRepository.findAll(notHidden(), sortedPageable);
    } else if (sourcesWhitelist != null) {
        return postRepository.findAll(notHidden()
            .and(
                QPost.post.title.containsIgnoreCase(query)
                    .or(QPost.post.contentText.containsIgnoreCase(query))
                    .or(QPost.post.sourceName.containsIgnoreCase(query))
            ).and(isAllowed(sourcesWhitelist)), sortedPageable);
    } else {
        return postRepository.findAll(notHidden()
            .and(
                QPost.post.title.containsIgnoreCase(query)
                    .or(QPost.post.contentText.containsIgnoreCase(query))
                    .or(QPost.post.sourceName.containsIgnoreCase(query))
            ), sortedPageable);
    }
}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:34,代码来源:PostController.java

示例6: findSlice

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public <T> Slice<T> findSlice(Query<T> query) {
    List<T> list = findAllInternal(query);
    Pageable pageable = query.getPageable();
    if (pageable != null) {
        boolean hasNext = ((pageable.getPageNumber() + 1) * pageable.getPageSize() < total(query));
        return new SliceImpl<T>(list, query.getPageable(), hasNext);
    } else {
        return new SliceImpl<T>(list);
    }
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:12,代码来源:SnowdropTemplate.java

示例7: getUpcomingOccurrences

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public Page<Occurrence> getUpcomingOccurrences(final Pageable pageable) {
    final RScoredSortedSet<String> set = getUpcomingEventsFromStore();

    final int page = pageable.getPageNumber();
    final int count = pageable.getPageSize();

    final List<ScoredEntry<String>> occurrenceCollection = new ArrayList<>(set.entryRange(page * count, ((page + 1) * count) - 1));
    final Page<ScoredEntry<String>> occurrences = new PageImpl<>(occurrenceCollection, pageable, set.size());

    return occurrences
            .map(this::convertParsedEventToOccurrence);
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:14,代码来源:EventServiceImpl.java

示例8: findDishes

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@RequestMapping(value = "search", method = RequestMethod.GET)
  public ModelAndView findDishes(@QuerydslPredicate(root = Dish.class) Predicate predicate, @PageableDefault(sort = {"date"}, direction = Sort.Direction.DESC) Pageable pageable, ModelAndView modelAndView) {
Sort realSort = pageable.getSort().and(new Sort(Sort.Direction.ASC, "id"));
PageRequest pageRequest = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), realSort);
Page<Dish> page = dishRepo.findAll(predicate, pageRequest);
List<DishWebDTO> dishes = page.getContent().stream().map(dishDtoFactory::create).collect(Collectors.toList());
modelAndView.addObject("page", page);
modelAndView.addObject("dishes", dishes);
modelAndView.addObject("labels", getLabelsFromDishes());
modelAndView.addObject("categories", getCategoriesFromDishes());
modelAndView.addObject("mensas", mensaRepo.findAllByOrderByName());
      modelAndView.setViewName("search");
      return modelAndView;
  }
 
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:15,代码来源:MensaWebController.java

示例9: getAllTags

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * GET  /admin/tags -> get all the tags.
 */
@RequestMapping(value = "/admin/tags",
    method = RequestMethod.GET,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<List<Tag>> getAllTags(Pageable pageable)
    throws URISyntaxException {
    Pageable pageRequest = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), Sort.Direction.DESC, "id");
    Page<Tag> page = tagRepository.findAll(pageRequest);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/admin/tags");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:15,代码来源:TagResource.java

示例10: getAllTopics

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * GET  /topics -> get all the topics.
 */
@RequestMapping(value = "/topics",
    method = RequestMethod.GET,
    produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Topic>> getAllTopics(Pageable pageable)
    throws URISyntaxException {
    Pageable pageRequest = new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), Sort.Direction.DESC, "weight");
    Page<Topic> page = topicRepository.findAll(pageRequest);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/topics");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:14,代码来源:TopicResource.java

示例11: findAll

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
@Override
public final Page<T> findAll(final Specification<T> spec, final Pageable pageable) {
    final int fromIndex = pageable.getPageNumber() * pageable.getPageSize();
    if (fromIndex >= values.size()) {
        return new PageImpl<>(Collections.<T>emptyList(), pageable, values.size());
    }
    int toIndex = pageable.getPageNumber() * pageable.getPageSize() + pageable.getPageSize();
    if (toIndex > values.size()) {
        toIndex = values.size();
    }

    return new PageImpl<>(values.subList(fromIndex, toIndex), pageable, values.size());
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:14,代码来源:EnumReadonlyRepository.java

示例12: adaptPageble

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
/**
 * Adapt the pageable to handle defaults.
 *
 * @param pageable pageable
 * @return adapted pageable
 */
private Pageable adaptPageble(final Pageable pageable) {
    final int page = pageable == null ? 0 : pageable.getPageNumber();
    final int size = pageable == null ? DEFAULT_PAGE_SIZE : pageable.getPageSize();

    return new PageRequest(page, size, adaptSort(pageable == null ? null : pageable.getSort()));
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:13,代码来源:AbstractBaseReadonlyController.java

示例13: PageDTO

import org.springframework.data.domain.Pageable; //导入方法依赖的package包/类
public PageDTO(List<T> content, Pageable pageable, long total) {
  this.total = total;
  this.content = content;
  this.page = pageable.getPageNumber();
  this.size = pageable.getPageSize();
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:7,代码来源:PageDTO.java


注:本文中的org.springframework.data.domain.Pageable.getPageNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。