diff --git a/src/main/java/org/springframework/data/domain/Sort.java b/src/main/java/org/springframework/data/domain/Sort.java index 9376885c5..78d9725b7 100644 --- a/src/main/java/org/springframework/data/domain/Sort.java +++ b/src/main/java/org/springframework/data/domain/Sort.java @@ -15,6 +15,7 @@ */ package org.springframework.data.domain; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -31,6 +32,7 @@ import org.springframework.data.util.MethodInvocationRecorder.Recorded; import org.springframework.data.util.Streamable; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -45,7 +47,7 @@ import org.springframework.util.StringUtils; */ public class Sort implements Streamable, Serializable { - private static final long serialVersionUID = 5737186511678863905L; + private static final @Serial long serialVersionUID = 5737186511678863905L; private static final Sort UNSORTED = Sort.by(new Order[0]); @@ -63,7 +65,7 @@ public class Sort implements Streamable properties) { + private Sort(Direction direction, @Nullable List properties) { if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("You have to provide at least one property to sort by"); @@ -78,7 +80,7 @@ public class Sort implements Streamable orders) { @@ -106,7 +108,7 @@ public class Sort implements Streamable TypedSort sort(Class type) { @@ -147,7 +149,7 @@ public class Sort implements Streamable iterator() { return this.orders.iterator(); } @@ -278,12 +288,6 @@ public class Sort implements Streamable result = new ArrayList<>(orders.size()); @@ -307,7 +311,7 @@ public class Sort implements Streamable fromOptionalString(String value) { - if (value == null) { + if (ObjectUtils.isEmpty(value)) { return Optional.empty(); } @@ -396,7 +401,8 @@ public class Sort implements Streamable extends Sort { - private static final long serialVersionUID = -3550403511206745880L; + private static final @Serial long serialVersionUID = -3550403511206745880L; private final Recorded recorded; @@ -739,7 +745,7 @@ public class Sort implements Streamable it.matches(field.getName(), field.getType())); + return UNMAPPED_PROPERTIES.stream()// + .noneMatch(it -> it.matches(field.getName(), field.getType())); } /** @@ -754,8 +755,8 @@ public abstract class AbstractMappingContext it.matches(property.getName(), property.getType())); + return UNMAPPED_PROPERTIES.stream()// + .noneMatch(it -> it.matches(property.getName(), property.getType())); } /**