当前位置: 首页>>代码示例>>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;未经允许,请勿转载。