当前位置: 首页>>代码示例>>Java>>正文


Java Sort.Direction方法代码示例

本文整理汇总了Java中org.springframework.data.domain.Sort.Direction方法的典型用法代码示例。如果您正苦于以下问题:Java Sort.Direction方法的具体用法?Java Sort.Direction怎么用?Java Sort.Direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.domain.Sort的用法示例。


在下文中一共展示了Sort.Direction方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildSort

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
private Collection<SortField<?>> buildSort(final Sort sortSpecification){
    Collection<SortField<?>> querySortFields = new ArrayList<>(10);

    if (sortSpecification == null) {
        // What is the default sorting?
        // Consistent way to write it in all app?
        return querySortFields;
    }

    List<String> usedSortKey = new ArrayList<>(10);

    for (final Sort.Order specifiedField : sortSpecification) {
        String sortFieldName = specifiedField.getProperty();
        Sort.Direction sortDirection = specifiedField.getDirection();

        if (usedSortKey.contains(sortFieldName))
            throw new IllegalArgumentException("Well how should it be handled? And should be same for all app to be consistent");

        querySortFields.add(getSortedField(sortFieldName, sortDirection));
        usedSortKey.add(sortFieldName);
    }
    return querySortFields;
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:24,代码来源:TransferTimingPageRepositoryImplPureJooq.java

示例2: getSortedField

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
private SortField<?> getSortedField(final String sortFieldName, final Sort.Direction sortDirection){
    SortOrder sortOrder;
    if (sortDirection == Sort.Direction.ASC) {
        sortOrder = SortOrder.ASC;
    } else {
        sortOrder = SortOrder.DESC;
    }
    switch (sortFieldName){
        case "id":
            return TRANSFER_TIMING_FILE_TRANSITION_HISTORY_ID.sort(sortOrder);
        case "atableName":
            return ATABLE.NAME.sort(sortOrder);
        case "username":
            return USER.USERNAME.sort(sortOrder);
        case "blablabla......... etc":
            // Etc for others
            return null;
        default:
            throw new IllegalArgumentException("Well how should it be handled? And should be same for all app to be consistent");
    }
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:22,代码来源:TransferTimingPageRepositoryImplPureJooq.java

示例3: buildOrderBy

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
/**
 * TODO Change to List for return value
 *
 * @param sortSpecification Sort from Spring Data
 * @return Collection of fields to sort (can be empty if {@code sortSpecification} is null or no sort values)
 * @throws SortingApiException if any sort field given cannot be found (it should result in a 400 error message) or sort contains duplicate keys
 */
@NotNull
default Collection<SortField<?>> buildOrderBy(@Nullable final Sort sortSpecification) {
    Collection<SortField<?>> querySortFields = new ArrayList<>(10);

    if (sortSpecification == null) {
        return getDefaultSorting();
    }

    List<String> usedSortKey = new ArrayList<>(10);

    for (final Sort.Order specifiedField : sortSpecification) {
        String sortFieldName = specifiedField.getProperty();
        Sort.Direction sortDirection = specifiedField.getDirection();

        if (usedSortKey.contains(sortFieldName))
            throw new SortingApiException("Cannot sort on duplicate keys");

        SortValue sortValue = getTableField(sortFieldName);
        SortField<?> querySortField = convertTableFieldToSortField(sortValue, sortDirection);
        querySortFields.add(querySortField);
        usedSortKey.add(sortFieldName);
    }

    return querySortFields;
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:33,代码来源:SortingJooq.java

示例4: curPage

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
@RequestMapping(value = "/curpage")
public List<UserEntity> curPage(int page){
	UserEntity user = new UserEntity();
	user.setSize(2);
	user.setPage(page);
	user.setSort("desc");
	Sort.Direction direction = Sort.Direction.DESC;
	Sort sort = new Sort(direction, "name");
	PageRequest pageRequest = new PageRequest(user.getPage() - 1, user.getSize(), sort);
	List<UserEntity> res = userService.curPage(pageRequest);
	return res;
}
 
开发者ID:SnailFastGo,项目名称:springboot_op,代码行数:13,代码来源:UserController.java

示例5: order

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
@Nonnull
@Override
public QueryBuilder<E> order(String field, Sort.Direction direction) {
    Sort newSort = new Sort(new Sort.Order(direction, field));
    this.sort = this.sort != null ? this.sort.and(newSort) : newSort;

    return this;
}
 
开发者ID:n15g,项目名称:spring-boot-gae,代码行数:9,代码来源:QueryImpl.java

示例6: convertTableFieldToSortField

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
/**
 * Is not supposed to be called from external of interface (might be private in Java 9)
 *
 * @param sortValue     SortValue to get SortField from
 * @param sortDirection Direction of sorting from request
 * @return A field sorted for jOOQ
 */
@NotNull
default SortField<?> convertTableFieldToSortField(SortValue sortValue, Sort.Direction sortDirection) {
    if (sortDirection == Sort.Direction.ASC) {
        return sortValue.getSortField(SortOrder.ASC);
    } else {
        return sortValue.getSortField(SortOrder.DESC);
    }
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:16,代码来源:SortingJooq.java

示例7: findEvents

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
@Override
public List<Event> findEvents(UUID tenantId, EntityId entityId, String eventType, TimePageLink pageLink) {
    Specification<EventEntity> timeSearchSpec = JpaAbstractSearchTimeDao.<EventEntity>getTimeSearchPageSpec(pageLink, "id");
    Specification<EventEntity> fieldsSpec = getEntityFieldsSpec(tenantId, entityId, eventType);
    Sort.Direction sortDirection = pageLink.isAscOrder() ? Sort.Direction.ASC : Sort.Direction.DESC;
    Pageable pageable = new PageRequest(0, pageLink.getLimit(), sortDirection, ID_PROPERTY);
    return DaoUtil.convertDataList(eventRepository.findAll(where(timeSearchSpec).and(fieldsSpec), pageable).getContent());
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:9,代码来源:JpaBaseEventDao.java

示例8: order

import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
/**
 * Order results.
 * The sequence in which multiple orders are specified will determine the final {@link Sort} order.
 *
 * @param field     The field to order by.
 * @param direction The direction to order by.
 * @return Query builder.
 */
@Nonnull
QueryBuilder<E> order(String field, Sort.Direction direction);
 
开发者ID:n15g,项目名称:spring-boot-gae,代码行数:11,代码来源:QueryBuilder.java


注:本文中的org.springframework.data.domain.Sort.Direction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。