本文整理汇总了Java中org.springframework.data.domain.Sort.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java Sort.iterator方法的具体用法?Java Sort.iterator怎么用?Java Sort.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.domain.Sort
的用法示例。
在下文中一共展示了Sort.iterator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: orderByExpression
import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
protected String orderByExpression(Sort sort) {
final String noSort = "";
if (sort == null || !sort.iterator().hasNext()) {
return noSort;
}
StringBuilder sb = new StringBuilder(" ORDER BY ");
for (Iterator<Order> it = sort.iterator(); it.hasNext(); ) {
Order order = it.next();
sb.append(order.getProperty()).append(' ').append(order.getDirection());
if (it.hasNext()) {
sb.append(COMMA);
}
}
return sb.toString();
}
示例2: sortQuery
import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
private Query<T> sortQuery(Query<T> query, Sort sort){
if (sort == null){
return query;
}
Order order;
for (Iterator<Order> iter=sort.iterator(); iter.hasNext(); ){
order=iter.next();
String condition = order.getProperty();
if (order.getDirection().isDescending()){
condition = "-" + condition;
}
query = query.order(condition);
}
return query;
}
示例3: orderByExpression
import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
protected String orderByExpression(Sort sort) {
StringBuilder sb = new StringBuilder();
for (Iterator<Order> it = sort.iterator(); it.hasNext(); ) {
Order order = it.next();
sb.append(order.getProperty()).append(' ').append(order.getDirection());
if (it.hasNext()) {
sb.append(COMMA);
}
}
return sb.toString();
}
示例4: findAll
import org.springframework.data.domain.Sort; //导入方法依赖的package包/类
@Override
public Iterable<D> findAll(Sort sort) {
Assert.notNull(sort, "sort must not be null");
Iterator<Sort.Order> iter = sort.iterator();
String query = findAllQuery + "ORDER BY ";
while (iter.hasNext()) {
Sort.Order order = iter.next();
query = query + order.getProperty() + " " + order.getDirection();
if (iter.hasNext()) {
query = query + ", ";
}
}
return jdbcTemplate.query(query, rowMapper);
}