本文整理匯總了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.");
}
}