private static List<Order> makeAdjustedOrders(List<Order> orders, List<Filter> filters) {
List<Order> existsOrders = Lists.newArrayList();
for (Filter filter : filters) {
if (filter.getOpEnum() == Filter.Operator.EXISTS) {
existsOrders.add(new Order()
.setProperty(filter.getProperty(0).getName())
.setDirection(Direction.ASCENDING));
}
}
Collections.sort(existsOrders, ORDER_PROPERTY_COMPARATOR);
List<Order> adjusted = new ArrayList<Order>(orders.size() + existsOrders.size() + 1);
adjusted.addAll(orders);
if (adjusted.isEmpty()) {
for (Filter filter : filters) {
if (ValidatedQuery.INEQUALITY_OPERATORS.contains(filter.getOpEnum())) {
adjusted.add(new Order()
.setProperty(filter.getProperty(0).getName())
.setDirection(Direction.ASCENDING));
break;
}
}