本文整理汇总了Java中org.springframework.data.domain.Sort.and方法的典型用法代码示例。如果您正苦于以下问题:Java Sort.and方法的具体用法?Java Sort.and怎么用?Java Sort.and使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.domain.Sort
的用法示例。
在下文中一共展示了Sort.and方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPageRequest
import org.springframework.data.domain.Sort; //导入方法依赖的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));
}
示例2: parseSort
import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
private Sort parseSort() {
Sort retVal = null;
if (StringUtils.hasLength(this.sortFields)) {
if (this.sortFields.indexOf(",") > -1) {
String[] sorts = StringUtils.split(this.sortFields, ",");
if (sorts != null) {
for (String oneSortStr : sorts) {
Sort oneSort = parseOneSort(oneSortStr.trim());
if (oneSort == null) {
continue;
}
if (retVal == null) {
retVal = oneSort;
} else {
retVal = retVal.and(oneSort);
}
}
}
} else {
retVal = parseOneSort(this.sortFields.trim());
}
}
return retVal;
}
示例3: executeInternal
import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
private Object executeInternal(ParametersParameterAccessor accessor) {
BaseQuery<?> query = createQuery(accessor);
Class<?> projectionClass = getProjection(accessor);
if (projectionClass != null) {
ProjectionInformation pi = getQueryMethod().getFactory().getProjectionInformation(projectionClass);
query.setProjectionInformation(pi);
}
Sort sort = query.getSort();
if (sort == null) {
sort = accessor.getSort();
} else {
sort = sort.and(accessor.getSort());
}
query.setSort(sort);
if (query.getPageable() == null) {
query.setPageable(accessor.getPageable());
}
if (isModify(query)) {
throw new UnsupportedOperationException("Hibernate Search repository support is read-only!");
} else if (getQueryMethod().isSliceQuery()) {
return snowdropOperations.findSlice(query);
} else if (getQueryMethod().isPageQuery()) {
return snowdropOperations.findPageable(query);
} else if (getQueryMethod().isStreamQuery()) {
return snowdropOperations.stream(query);
} else if (getQueryMethod().isCollectionQuery()) {
return snowdropOperations.findAll(query);
} else if (isCountProjection(query)) {
return snowdropOperations.count(query);
} else if (isExistsProjection(query)) {
return (snowdropOperations.count(query) > 0);
} else if ((projectionClass != null) || getQueryMethod().isQueryForEntity()) {
return snowdropOperations.findSingle(query);
} else {
throw new IllegalArgumentException("Invalid query type.");
}
}