Avoid Iterator allocations when calling Sort.isSorted().

Closes #2445
This commit is contained in:
Mark Paluch
2021-09-07 16:07:24 +02:00
parent c0d85aabc5
commit 242a71ca56
2 changed files with 14 additions and 0 deletions

View File

@@ -173,6 +173,11 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
return !isEmpty();
}
@Override
public boolean isEmpty() {
return orders.isEmpty();
}
public boolean isUnsorted() {
return !isSorted();
}
@@ -718,7 +723,11 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
.map(Order::by) //
.map(Collections::singleton) //
.orElseGet(Collections::emptySet).iterator();
}
@Override
public boolean isEmpty() {
return !recorded.getPropertyPath().isPresent();
}
/*

View File

@@ -104,6 +104,11 @@ public class QSort extends Sort implements Serializable {
return Order.by(targetElement.toString()).with(orderSpecifier.isAscending() ? Direction.ASC : Direction.DESC);
}
@Override
public boolean isEmpty() {
return orderSpecifiers.isEmpty();
}
/**
* @return the orderSpecifier
*/