if (ormProperty.indexOf('.') == -1) { sort = Sort.by(new Sort.Order(Direction.valueOf(direction.toUpperCase(Locale.ENGLISH)), ormProperty) .ignoreCase()); } else { sort = JpaSort.unsafe(Direction.valueOf(direction.toUpperCase(Locale.ENGLISH)),
public static Sort covertSortDto(SortDto sortDto) { if (sortDto == null || sortDto.getOrders() == null || sortDto.getOrders().isEmpty()) { return null; } List<Order> orders = new ArrayList<>(); for (OrderDto orderdto : sortDto.getOrders()) { Order order = new Order(Sort.Direction.fromString(orderdto .getDirection().name()), orderdto.getProperty()); if (orderdto.isIgnoreCase()) { order = order.ignoreCase(); } orders.add(order); } return new Sort(orders); } }
/** * Transforms the comparator item into a {@code Sort.Order} object. * * @param comparatorItem * the comparator item * @return the sort object */ public static Sort.Order toSortOrder(ComparatorItem comparatorItem) { if (comparatorItem == null || comparatorItem.getField() == null || comparatorItem.getField().trim().length() == 0) { return null; } Sort.Direction direction = comparatorItem.isAsc() ? Sort.Direction.ASC : Sort.Direction.DESC; Sort.NullHandling nullHandlingHint = comparatorItem.isNullIsFirst() ? Sort.NullHandling.NULLS_FIRST : Sort.NullHandling.NULLS_LAST; Sort.Order order = new Sort.Order(direction, comparatorItem.getField(), nullHandlingHint); if (comparatorItem.isIgnoreCase()) { return order.ignoreCase(); } return order; }
public static final Order mapToOrder(OrderWrapper orderWrapper) { Direction springDirection = Direction.fromString(orderWrapper.getDirection()); Order order = null; if (orderWrapper.isIgnoreCase()) { order = new Order(springDirection, orderWrapper.getProperty()).ignoreCase(); } else { order = new Order(springDirection, orderWrapper.getProperty()); } return order; } }