本文整理了Java中org.springframework.data.querydsl.QSort
类的一些代码示例,展示了QSort
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QSort
类的具体详情如下:
包路径:org.springframework.data.querydsl.QSort
类名称:QSort
[英]Sort option for queries that wraps a Querydsl OrderSpecifier.
[中]用于包装Querydsl OrderSpecifier的查询的排序选项。
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Applies the given {@link OrderSpecifier}s to the given {@link JPQLQuery}. Potentially transforms the given
* {@code OrderSpecifier}s to be able to injection potentially necessary left-joins.
*
* @param qsort must not be {@literal null}.
* @param query must not be {@literal null}.
*/
private <T> JPQLQuery<T> addOrderByFrom(QSort qsort, JPQLQuery<T> query) {
List<OrderSpecifier<?>> orderSpecifiers = qsort.getOrderSpecifiers();
return query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[0]));
}
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Executes the given {@link JPQLQuery} after applying the given {@link OrderSpecifier}s.
*
* @param query must not be {@literal null}.
* @param orders must not be {@literal null}.
* @return
*/
private List<T> executeSorted(JPQLQuery<T> query, OrderSpecifier<?>... orders) {
return executeSorted(query, new QSort(orders));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Returns a new {@link QSort} consisting of the {@link OrderSpecifier}s of the current {@code QSort} combined with
* the ones from the given {@code QSort}.
*
* @param sort can be {@literal null}.
* @return
*/
public QSort and(QSort sort) {
return sort == null ? this : and(sort.getOrderSpecifiers());
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Creates a new {@link QPageRequest}. Pages are zero indexed, thus providing 0 for {@code page} will return the first
* page.
*
* @param page
* @param size
*/
public QPageRequest(int page, int size) {
this(page, size, QSort.unsorted());
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Creates a new {@link QSort} instance with the given {@link OrderSpecifier}s.
*
* @param orderSpecifiers must not be {@literal null}.
*/
@SuppressWarnings("deprecation")
public QSort(List<OrderSpecifier<?>> orderSpecifiers) {
super(toOrders(orderSpecifiers));
this.orderSpecifiers = orderSpecifiers;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Returns a new {@link QSort} consisting of the {@link OrderSpecifier}s of the current {@link QSort} combined with
* the given ones.
*
* @param orderSpecifiers must not be {@literal null} or empty.
* @return
*/
public QSort and(OrderSpecifier<?>... orderSpecifiers) {
Assert.notEmpty(orderSpecifiers, "OrderSpecifiers must not be null or empty!");
return and(Arrays.asList(orderSpecifiers));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Converts the given {@link OrderSpecifier} into an {@link Order}.
*
* @param orderSpecifier must not be {@literal null}.
* @return
*/
private static Order toOrder(OrderSpecifier<?> orderSpecifier) {
Assert.notNull(orderSpecifier, "Order specifier must not be null!");
Expression<?> target = orderSpecifier.getTarget();
Object targetElement = target instanceof Path ? preparePropertyPath((Path<?>) target) : target;
Assert.notNull(targetElement, "Target element must not be null!");
return Order.by(targetElement.toString()).with(orderSpecifier.isAscending() ? Direction.ASC : Direction.DESC);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
/**
* Converts the given {@link Sort} to {@link OrderSpecifier}.
*
* @param sort
* @return
*/
protected List<OrderSpecifier<?>> toOrderSpecifiers(Sort sort) {
if (sort instanceof QSort) {
return ((QSort) sort).getOrderSpecifiers();
}
return sort.stream().map(this::toOrder).collect(Collectors.toList());
}
代码示例来源:origin: spring-projects/spring-data-jpa
/**
* Executes the given {@link JPQLQuery} after applying the given {@link OrderSpecifier}s.
*
* @param query must not be {@literal null}.
* @param orders must not be {@literal null}.
* @return
*/
private List<T> executeSorted(JPQLQuery<T> query, OrderSpecifier<?>... orders) {
return executeSorted(query, new QSort(orders));
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
/**
* Applies the given {@link Sort} to the given {@link SpringDataMongodbQuery}.
*
* @param query
* @param sort
* @return
*/
private SpringDataMongodbQuery<T> applySorting(SpringDataMongodbQuery<T> query, Sort sort) {
// TODO: find better solution than instanceof check
if (sort instanceof QSort) {
List<OrderSpecifier<?>> orderSpecifiers = ((QSort) sort).getOrderSpecifiers();
query.orderBy(orderSpecifiers.toArray(new OrderSpecifier<?>[orderSpecifiers.size()]));
return query;
}
sort.stream().map(this::toOrder).forEach(query::orderBy);
return query;
}
代码示例来源:origin: apache/servicemix-bundles
public static QSort by(OrderSpecifier<?>... orderSpecifiers) {
return new QSort(orderSpecifiers);
}
代码示例来源:origin: org.springframework.data/spring-data-jpa
/**
* Applies the given {@link OrderSpecifier}s to the given {@link JPQLQuery}. Potentially transforms the given
* {@code OrderSpecifier}s to be able to injection potentially necessary left-joins.
*
* @param qsort must not be {@literal null}.
* @param query must not be {@literal null}.
*/
private <T> JPQLQuery<T> addOrderByFrom(QSort qsort, JPQLQuery<T> query) {
List<OrderSpecifier<?>> orderSpecifiers = qsort.getOrderSpecifiers();
return query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[0]));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Creates a new {@link QPageRequest} with the given {@link OrderSpecifier}s applied.
*
* @param page
* @param size
* @param orderSpecifiers must not be {@literal null} or empty;
*/
public QPageRequest(int page, int size, OrderSpecifier<?>... orderSpecifiers) {
this(page, size, new QSort(orderSpecifiers));
}
代码示例来源:origin: org.springframework.data/spring-data-keyvalue
/**
* Transforms a plain {@link Order} into a QueryDsl specific {@link OrderSpecifier}.
*
* @param sort must not be {@literal null}.
* @param builder must not be {@literal null}.
* @return empty {@code OrderSpecifier<?>[]} when sort is {@literal null}.
*/
static OrderSpecifier<?>[] toOrderSpecifier(Sort sort, PathBuilder<?> builder) {
Assert.notNull(sort, "Sort must not be null.");
Assert.notNull(builder, "Builder must not be null.");
List<OrderSpecifier<?>> specifiers = null;
if (sort instanceof QSort) {
specifiers = ((QSort) sort).getOrderSpecifiers();
} else {
specifiers = new ArrayList<>();
for (Order order : sort) {
specifiers.add(toOrderSpecifier(order, builder));
}
}
return specifiers.toArray(new OrderSpecifier<?>[specifiers.size()]);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Returns a new {@link QSort} consisting of the {@link OrderSpecifier}s of the current {@link QSort} combined with
* the given ones.
*
* @param orderSpecifiers must not be {@literal null} or empty.
* @return
*/
public QSort and(List<OrderSpecifier<?>> orderSpecifiers) {
Assert.notEmpty(orderSpecifiers, "OrderSpecifiers must not be null or empty!");
List<OrderSpecifier<?>> newOrderSpecifiers = new ArrayList<>(this.orderSpecifiers);
newOrderSpecifiers.addAll(orderSpecifiers);
return new QSort(newOrderSpecifiers);
}
代码示例来源:origin: spring-projects/spring-data-keyvalue
/**
* Transforms a plain {@link Order} into a QueryDsl specific {@link OrderSpecifier}.
*
* @param sort must not be {@literal null}.
* @param builder must not be {@literal null}.
* @return empty {@code OrderSpecifier<?>[]} when sort is {@literal null}.
*/
static OrderSpecifier<?>[] toOrderSpecifier(Sort sort, PathBuilder<?> builder) {
Assert.notNull(sort, "Sort must not be null.");
Assert.notNull(builder, "Builder must not be null.");
List<OrderSpecifier<?>> specifiers = null;
if (sort instanceof QSort) {
specifiers = ((QSort) sort).getOrderSpecifiers();
} else {
specifiers = new ArrayList<>();
for (Order order : sort) {
specifiers.add(toOrderSpecifier(order, builder));
}
}
return specifiers.toArray(new OrderSpecifier<?>[specifiers.size()]);
}
代码示例来源:origin: org.springframework.data/spring-data-jpa
/**
* Executes the given {@link JPQLQuery} after applying the given {@link OrderSpecifier}s.
*
* @param query must not be {@literal null}.
* @param orders must not be {@literal null}.
* @return
*/
private List<T> executeSorted(JPQLQuery<T> query, OrderSpecifier<?>... orders) {
return executeSorted(query, new QSort(orders));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Transforms a plain {@link Order} into a QueryDsl specific {@link OrderSpecifier}.
*
* @param sort must not be {@literal null}.
* @param builder must not be {@literal null}.
* @return empty {@code OrderSpecifier<?>[]} when sort is {@literal null}.
*/
static OrderSpecifier<?>[] toOrderSpecifier(Sort sort, PathBuilder<?> builder) {
Assert.notNull(sort, "Sort must not be null.");
Assert.notNull(builder, "Builder must not be null.");
List<OrderSpecifier<?>> specifiers = null;
if (sort instanceof QSort) {
specifiers = ((QSort) sort).getOrderSpecifiers();
} else {
specifiers = new ArrayList<>();
for (Order order : sort) {
specifiers.add(toOrderSpecifier(order, builder));
}
}
return specifiers.toArray(new OrderSpecifier<?>[specifiers.size()]);
}
代码示例来源:origin: org.springframework.data/spring-data-jpa
/**
* Executes the given {@link JPQLQuery} after applying the given {@link OrderSpecifier}s.
*
* @param query must not be {@literal null}.
* @param orders must not be {@literal null}.
* @return
*/
private List<T> executeSorted(JPQLQuery<T> query, OrderSpecifier<?>... orders) {
return executeSorted(query, new QSort(orders));
}
内容来源于网络,如有侵权,请联系作者删除!