本文整理汇总了Java中com.mysema.query.types.Order.ASC属性的典型用法代码示例。如果您正苦于以下问题:Java Order.ASC属性的具体用法?Java Order.ASC怎么用?Java Order.ASC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.mysema.query.types.Order
的用法示例。
在下文中一共展示了Order.ASC属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOrderSpecifier
/**
* {@inheritDoc}
*/
@Override
public <T, E extends Comparable<?>> OrderSpecifier<?> createOrderSpecifier(
PathBuilder<T> entityPath, String fieldName, Class<E> fieldType,
Order order) {
OrderSpecifier<?> orderBy = null;
// Get the OrderSpecifier
if (order == Order.ASC) {
orderBy = entityPath.getComparable(fieldName, fieldType).asc();
}
else if (order == Order.DESC) {
orderBy = entityPath.getComparable(fieldName, fieldType).desc();
}
return orderBy;
}
示例2: applyListParams
private <T extends Comparable<? super T>> SQLQuery applyListParams(SQLQuery query, ListQuery listQuery, ComparableExpressionBase<T> orderBy) {
Order order = listQuery.getOrder();
Long limit = listQuery.getLimit();
Long offset = listQuery.getOffset();
if(order != null) {
if(order == Order.ASC) {
query = query.orderBy(orderBy.asc());
} else {
query = query.orderBy(orderBy.desc());
}
}
if(limit != null) {
query = query.limit(limit);
}
if(offset != null) {
query = query.offset(offset);
}
return query;
}
示例3: createOrderSpecifier
/**
* Create an order-by-element in a Query instance
*
* @param entityPath Full path to entity and associations. For example:
* {@code Pet} , {@code Pet.owner}
* @param fieldName Property name in the given entity path. For example:
* {@code weight} in {@code Pet} entity, {@code age} in
* {@code Pet.owner} entity.
* @param fieldType Property value {@code Class}. Must implements
* {@link Comparable}
* @param order ascending or descending order
* @return
*/
public static <T, E extends Comparable<?>> OrderSpecifier<?> createOrderSpecifier(
PathBuilder<T> entityPath, String fieldName, Class<E> fieldType,
Order order) {
OrderSpecifier<?> orderBy = null;
// Get the OrderSpecifier
if (order == Order.ASC) {
orderBy = entityPath.getComparable(fieldName, fieldType).asc();
}
else if (order == Order.DESC) {
orderBy = entityPath.getComparable(fieldName, fieldType).desc();
}
return orderBy;
}
示例4: addSorting
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void addSorting(ExtDirectStoreReadRequest request, JPQLQuery query,
PathBuilder<?> pathBuilder) {
Class<?> clazz = getTypeClass();
if (!request.getSorters().isEmpty()) {
for (SortInfo sortInfo : request.getSorters()) {
Order order;
if (sortInfo.getDirection() == SortDirection.ASCENDING) {
order = Order.ASC;
}
else {
order = Order.DESC;
}
Field field = ReflectionUtils.findField(clazz, sortInfo.getProperty());
SortProperty sortProperty = field.getAnnotation(SortProperty.class);
if (sortProperty != null) {
String[] splittedValue = sortProperty.value().split("\\.");
field = ReflectionUtils.findField(clazz, splittedValue[0]);
PathBuilder path = new PathBuilder(field.getType(), splittedValue[0]);
query.leftJoin(pathBuilder.get(splittedValue[0]), path);
query.orderBy(new OrderSpecifier(order, path.get(splittedValue[1])));
}
else {
query.orderBy(new OrderSpecifier(order, pathBuilder.get(sortInfo
.getProperty())));
}
}
}
}
示例5: createOrderSpecifiers
@SuppressWarnings({ "rawtypes", "unchecked" })
public static OrderSpecifier[] createOrderSpecifiers(
ExtDirectStoreReadRequest request, Class<?> clazz,
EntityPathBase<?> entityPathBase, Map<String, String> mapGuiColumn2Dbfield,
Set<String> sortIgnoreProperties) {
List<OrderSpecifier> orders;
if (!request.getSorters().isEmpty()) {
orders = new ArrayList<>();
PathBuilder<?> entityPath = new PathBuilder<>(clazz,
entityPathBase.getMetadata());
for (SortInfo sortInfo : request.getSorters()) {
if (!sortIgnoreProperties.contains(sortInfo.getProperty())) {
Order order;
if (sortInfo.getDirection() == SortDirection.ASCENDING) {
order = Order.ASC;
}
else {
order = Order.DESC;
}
String property = mapGuiColumn2Dbfield.get(sortInfo.getProperty());
if (property == null) {
property = sortInfo.getProperty();
}
orders.add(new OrderSpecifier(order, entityPath.get(property)));
}
}
}
else {
orders = Collections.emptyList();
}
return orders.toArray(new OrderSpecifier[orders.size()]);
}
示例6: sort
public void sort(OrderSpecifier<?>... order) {
Object[] propertyId = new Object[order.length];
boolean[] ascending = new boolean[order.length];
for (int i = 0; i < order.length; i++) {
propertyId[i] = ((Path)order[i].getTarget()).getMetadata().getName();
ascending[i] = order[i].getOrder() == Order.ASC;
}
super.sort(propertyId, ascending);
}
示例7: getOrderSpecifier
@SuppressWarnings("unchecked")
private Optional<OrderSpecifier> getOrderSpecifier(QueryParameters parameters, Expression<?>... args) {
final String sortColumn = parameters.getSortColumn();
final String sortDirection = parameters.getSortDirection();
if (StringUtils.hasText(sortColumn) && StringUtils.hasText(sortDirection)) {
Order order = (Sort.Direction.ASC.compareTo(pageableFactory.getDirection(sortDirection)) == 0) ? Order.ASC : Order.DESC;
return Optional.of(new OrderSpecifier(order, new EntityPathBase(args[0].getType(), suppressUniquePrefixIfAny(sortColumn))));
}
return Optional.absent();
}
示例8: transformOrder
private <T extends Comparable> OrderSpecifier<T> transformOrder(QueryOrder<T> queryOrder) {
return new OrderSpecifier<>(queryOrder.isAsc() ? Order.ASC : Order.DESC, queryOrder.getTarget());
}