org.springframework.data.domain.Pageable.isUnpaged()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(250)

本文整理了Java中org.springframework.data.domain.Pageable.isUnpaged()方法的一些代码示例,展示了Pageable.isUnpaged()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pageable.isUnpaged()方法的具体详情如下:
包路径:org.springframework.data.domain.Pageable
类名称:Pageable
方法名:isUnpaged

Pageable.isUnpaged介绍

[英]Returns whether the current Pageable does not contain pagination information.
[中]返回当前分页表是否不包含分页信息。

代码示例

代码示例来源:origin: spring-projects/spring-data-jpa

private static boolean isUnpaged(Pageable pageable) {
  return pageable.isUnpaged();
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Sets the given pagination information on the {@link Query} instance. Will transparently set {@code skip} and
 * {@code limit} as well as applying the {@link Sort} instance defined with the {@link Pageable}.
 *
 * @param pageable
 * @return
 */
public Query with(Pageable pageable) {
  if (pageable.isUnpaged()) {
    return this;
  }
  this.limit = pageable.getPageSize();
  this.skip = pageable.getOffset();
  return with(pageable.getSort());
}

代码示例来源:origin: spring-projects/spring-data-jpa

/**
   * Binds the parameters to the given query and applies special parameter types (e.g. pagination).
   *
   * @param query must not be {@literal null}.
   * @param values values of method parameters to be assigned to the query parameters.
   */
  Query bindAndPrepare(Query query, Object[] values) {

    Assert.notNull(query, "Query must not be null!");

    ParametersParameterAccessor accessor = new ParametersParameterAccessor(parameters, values);

    Query result = bind(query, values);

    if (!useJpaForPaging || !parameters.hasPageableParameter() || accessor.getPageable().isUnpaged()) {
      return result;
    }

    result.setFirstResult((int) accessor.getPageable().getOffset());
    result.setMaxResults(accessor.getPageable().getPageSize());

    return result;
  }
}

代码示例来源:origin: spring-projects/spring-data-jpa

/**
 * Applies the given {@link Pageable} to the given {@link JPQLQuery}.
 *
 * @param pageable
 * @param query must not be {@literal null}.
 * @return the Querydsl {@link JPQLQuery}.
 */
public <T> JPQLQuery<T> applyPagination(Pageable pageable, JPQLQuery<T> query) {
  if (pageable.isUnpaged()) {
    return query;
  }
  query.offset(pageable.getOffset());
  query.limit(pageable.getPageSize());
  return applySorting(pageable.getSort(), query);
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

/**
 * Sets the given pagination information on the {@link Query} instance. Will transparently set {@code skip} and
 * {@code limit} as well as applying the {@link Sort} instance defined with the {@link Pageable}.
 *
 * @param pageable
 * @return
 */
public Query with(Pageable pageable) {
  if (pageable.isUnpaged()) {
    return this;
  }
  this.limit = pageable.getPageSize();
  this.skip = pageable.getOffset();
  return with(pageable.getSort());
}

代码示例来源:origin: org.springframework.data/spring-data-jpa

private static boolean isUnpaged(Pageable pageable) {
  return pageable.isUnpaged();
}

代码示例来源:origin: alibaba/sca-best-practice

private static boolean isUnpaged(Pageable pageable) {
  return pageable.isUnpaged();
}

代码示例来源:origin: apache/servicemix-bundles

/**
   * Returns an {@link Optional} so that it can easily be mapped on.
   *
   * @return
   */
  default Optional<Pageable> toOptional() {
    return isUnpaged() ? Optional.empty() : Optional.of(this);
  }
}

代码示例来源:origin: com.arangodb/arangodb-spring-data

public static String buildLimitClause(final Pageable pageable) {
  if (pageable.isUnpaged()) {
    return "";
  }
  final StringJoiner clause = new StringJoiner(", ", "LIMIT ", "");
  clause.add(String.valueOf(pageable.getOffset()));
  clause.add(String.valueOf(pageable.getPageSize()));
  return clause.toString();
}

代码示例来源:origin: arangodb/spring-data

public static String buildLimitClause(final Pageable pageable) {
  if (pageable.isUnpaged()) {
    return "";
  }
  final StringJoiner clause = new StringJoiner(", ", "LIMIT ", "");
  clause.add(String.valueOf(pageable.getOffset()));
  clause.add(String.valueOf(pageable.getPageSize()));
  return clause.toString();
}

代码示例来源:origin: com.arangodb/arangodb-spring-data

private static StringBuilder buildPageableClause(
  final Pageable pageable,
  @Nullable final String varName,
  final StringBuilder clause) {
  if (pageable.isUnpaged()) {
    return clause;
  }
  final Sort sort = pageable.getSort();
  buildSortClause(sort, varName, clause);
  if (sort.isSorted()) {
    clause.append(' ');
  }
  clause.append("LIMIT ").append(pageable.getOffset()).append(", ").append(pageable.getPageSize());
  return clause;
}

代码示例来源:origin: arangodb/spring-data

private static StringBuilder buildPageableClause(
  final Pageable pageable,
  @Nullable final String varName,
  final StringBuilder clause) {
  if (pageable.isUnpaged()) {
    return clause;
  }
  final Sort sort = pageable.getSort();
  buildSortClause(sort, varName, clause);
  if (sort.isSorted()) {
    clause.append(' ');
  }
  clause.append("LIMIT ").append(pageable.getOffset()).append(", ").append(pageable.getPageSize());
  return clause;
}

代码示例来源:origin: pramoth/specification-with-projection

private <R> Page<R> readPageWithProjection(Specification<T> spec, Class<R> projectionType, Pageable pageable, TypedQuery<T> query) {
  if (log.isDebugEnabled()) {
    query.getHints().forEach((key, value) -> log.info("apply query hints -> {} : {}", key, value));
  }
  Page<T> result = pageable.isUnpaged() ? new PageImpl<>(query.getResultList()) : readPage(query, getDomainClass(), pageable, spec);
  return result.map(item -> projectionFactory.createProjection(projectionType, item));
}

代码示例来源:origin: spring-projects/spring-data-solr

/**
 * @param criteria
 * @param pageable
 */
public SimpleQuery(Criteria criteria, @Nullable Pageable pageable) {
  super(criteria);
  if (pageable != null && !pageable.isUnpaged()) {
    this.offset = pageable.getOffset();
    this.rows = pageable.getPageSize();
    this.addSort(pageable.getSort());
  }
}

代码示例来源:origin: hatunet/spring-data-mybatis

@Override
public <X extends T> Page<T> findAll(Pageable pageable, X condition) {
  if (null == pageable || pageable.isUnpaged()) {
    // FIXME USE A DEFAULT PAGEABLE?
    return new PageImpl<>(findAll(condition));
  }
  return findByPager(pageable, "__find_by_pager", "__count", condition);
}

代码示例来源:origin: org.springframework.data/spring-data-jpa

/**
   * Binds the parameters to the given query and applies special parameter types (e.g. pagination).
   *
   * @param query must not be {@literal null}.
   * @param values values of method parameters to be assigned to the query parameters.
   */
  Query bindAndPrepare(Query query, Object[] values) {

    Assert.notNull(query, "Query must not be null!");

    ParametersParameterAccessor accessor = new ParametersParameterAccessor(parameters, values);

    Query result = bind(query, values);

    if (!useJpaForPaging || !parameters.hasPageableParameter() || accessor.getPageable().isUnpaged()) {
      return result;
    }

    result.setFirstResult((int) accessor.getPageable().getOffset());
    result.setMaxResults(accessor.getPageable().getPageSize());

    return result;
  }
}

代码示例来源:origin: org.springframework.data/spring-data-keyvalue

@Override
public Page<T> findAll(Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  if (pageable.isUnpaged()) {
    List<T> result = findAll();
    return new PageImpl<>(result, Pageable.unpaged(), result.size());
  }
  Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(),
      entityInformation.getJavaType());
  return new PageImpl<>(IterableConverter.toList(content), pageable,
      this.operations.count(entityInformation.getJavaType()));
}

代码示例来源:origin: spring-projects/spring-data-keyvalue

@Override
public Page<T> findAll(Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  if (pageable.isUnpaged()) {
    List<T> result = findAll();
    return new PageImpl<>(result, Pageable.unpaged(), result.size());
  }
  Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(),
      entityInformation.getJavaType());
  return new PageImpl<>(IterableConverter.toList(content), pageable,
      this.operations.count(entityInformation.getJavaType()));
}

代码示例来源:origin: org.springframework.data/spring-data-jpa

/**
 * Applies the given {@link Pageable} to the given {@link JPQLQuery}.
 *
 * @param pageable
 * @param query must not be {@literal null}.
 * @return the Querydsl {@link JPQLQuery}.
 */
public <T> JPQLQuery<T> applyPagination(Pageable pageable, JPQLQuery<T> query) {
  if (pageable.isUnpaged()) {
    return query;
  }
  query.offset(pageable.getOffset());
  query.limit(pageable.getPageSize());
  return applySorting(pageable.getSort(), query);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Page<T> findAll(Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  if (pageable.isUnpaged()) {
    List<T> result = findAll();
    return new PageImpl<>(result, Pageable.unpaged(), result.size());
  }
  Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(),
      entityInformation.getJavaType());
  return new PageImpl<>(IterableConverter.toList(content), pageable,
      this.operations.count(entityInformation.getJavaType()));
}

相关文章