public PageDTO(List<T> content, Pageable pageable, long total) { this.total = total; this.content = content; this.page = pageable.getPageNumber(); this.size = pageable.getPageSize(); }
Pageable topTen = new PageRequest(0, 10); Page<User> result = repository.findByUsername("Matthews", topTen); Assert.assertThat(result.isFirstPage(), is(true));
private static Direction toDirection(Sort sort, String property) { if (sort.isUnsorted()) { return Direction.DESC; } Order order = sort.getOrderFor(property); return order == null ? Direction.DESC : order.isAscending() ? Direction.ASC : Direction.DESC; } }
@GetMapping("/by-namespace/count") public long getInstancesCountByNamespace(@RequestParam("appId") String appId, @RequestParam("clusterName") String clusterName, @RequestParam("namespaceName") String namespaceName) { Page<Instance> instances = instanceService.findInstancesByNamespace(appId, clusterName, namespaceName, PageRequest.of(0, 1)); return instances.getTotalElements(); } }
public List<App> findAll(Pageable pageable) { Page<App> page = appRepository.findAll(pageable); return page.getContent(); }
private int check() { PageRequest pageable = PageRequest.of(0, 1); appService.findAll(pageable); return 0; }
/** * Define the {@literal minProperties}. * * @param count the allowed minimal number of properties. * @return new instance of {@link ObjectJsonSchemaObject}. */ public ObjectJsonSchemaObject minProperties(int count) { Bound<Integer> upper = this.propertiesCount != null ? this.propertiesCount.getUpperBound() : Bound.unbounded(); return propertiesCount(Range.of(Bound.inclusive(count), upper)); }
/** * Define the valid length range ({@literal maxLength}) for a valid field. * * @param length * @return new instance of {@link StringJsonSchemaObject}. */ public StringJsonSchemaObject maxLength(int length) { Bound<Integer> lower = this.length != null ? this.length.getLowerBound() : Bound.unbounded(); return length(Range.of(lower, Bound.inclusive(length))); }
@Override public boolean isIgnoreCase() { return super.isIgnoreCase() || ignoreCase; }
@Override public boolean isNew(T entity) { return entity.isNew(); }
/** * Return {@link Optional} lower bound from {@link Range}. * * @param range * @param <T> * @return * @since 2.0.9 */ static <T extends Comparable<T>> Optional<T> getLowerBound(org.springframework.data.domain.Range<T> range) { return range.getLowerBound().getValue(); }
/** * Return {@link Optional} upper bound from {@link Range}. * * @param range * @param <T> * @return * @since 2.0.9 */ static <T extends Comparable<T>> Optional<T> getUpperBound(org.springframework.data.domain.Range<T> range) { return range.getUpperBound().getValue(); }
Pageable topTen = new PageRequest(0, 10); List<User> result = repository.findByUsername("Matthews", topTen);
private int check() { PageRequest pageable = PageRequest.of(0, 1); appService.findAll(pageable); return 0; }
/** * Define the {@literal maxItems}. * * @param count the allowed minimal number of array items. * @return new instance of {@link ArrayJsonSchemaObject}. */ public ArrayJsonSchemaObject minItems(int count) { Bound<Integer> upper = this.range != null ? this.range.getUpperBound() : Bound.unbounded(); return range(Range.of(Bound.inclusive(count), upper)); }
/** * Define the {@literal maxProperties}. * * @param count the allowed maximum number of properties. * @return new instance of {@link ObjectJsonSchemaObject}. */ public ObjectJsonSchemaObject maxProperties(int count) { Bound<Integer> lower = this.propertiesCount != null ? this.propertiesCount.getLowerBound() : Bound.unbounded(); return propertiesCount(Range.of(lower, Bound.inclusive(count))); }
@Override public Page<EsProduct> search(String keyword, Integer pageNum, Integer pageSize) { Pageable pageable = new PageRequest(pageNum, pageSize); return productRepository.findByNameOrSubTitleOrKeywords(keyword, keyword, keyword, pageable); }
@Override public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { PageableHandlerMethodArgumentResolver pageResolver = new PageableHandlerMethodArgumentResolver(); pageResolver.setFallbackPageable(PageRequest.of(0, 10)); argumentResolvers.add(pageResolver); }
/** * Define the valid length range ({@literal minLength}) for a valid field. * * @param length * @return new instance of {@link StringJsonSchemaObject}. */ public StringJsonSchemaObject minLength(int length) { Bound<Integer> upper = this.length != null ? this.length.getUpperBound() : Bound.unbounded(); return length(Range.of(Bound.inclusive(length), upper)); }
/** * Define the {@literal maxItems}. * * @param count the allowed maximal number of array items. * @return new instance of {@link ArrayJsonSchemaObject}. */ public ArrayJsonSchemaObject maxItems(int count) { Bound<Integer> lower = this.range != null ? this.range.getLowerBound() : Bound.unbounded(); return range(Range.of(lower, Bound.inclusive(count))); }