當前位置: 首頁>>代碼示例>>Java>>正文


Java Sort.and方法代碼示例

本文整理匯總了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));
}
 
開發者ID:ATLANTBH,項目名稱:owl,代碼行數:33,代碼來源:ServicesUtils.java

示例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;
}
 
開發者ID:Kevin-Huang-NZ,項目名稱:springboot-jsp-generator,代碼行數:26,代碼來源:PageableFactory.java

示例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.");
    }
}
 
開發者ID:snowdrop,項目名稱:spring-data-snowdrop,代碼行數:42,代碼來源:AbstractSnowdropRepositoryQuery.java


注:本文中的org.springframework.data.domain.Sort.and方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。