當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。