From fd4e450a64f003fcf6b4276ce754853070e2c6b7 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 8 Oct 2025 16:14:49 +0200 Subject: [PATCH] Polishing. See #3377 --- .../data/mapping/PropertyPath.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/springframework/data/mapping/PropertyPath.java b/src/main/java/org/springframework/data/mapping/PropertyPath.java index 7a08e2751..1a0304e9e 100644 --- a/src/main/java/org/springframework/data/mapping/PropertyPath.java +++ b/src/main/java/org/springframework/data/mapping/PropertyPath.java @@ -64,11 +64,11 @@ public interface PropertyPath extends Streamable { PropertyPath result = this; - while (result.hasNext()) { + while (result != null && result.hasNext()) { result = result.next(); } - return result; + return result == null ? this : result; } /** @@ -158,8 +158,8 @@ public interface PropertyPath extends Streamable { } /** - * Returns an {@link Iterator } that iterates over all the partial property paths with the same leaf - * type but decreasing length. For example: + * Returns an {@link Iterator Iterator of PropertyPath} that iterates over all the partial property paths with the + * same leaf type but decreasing length. For example: * *
 	 * PropertyPath propertyPath = PropertyPath.from("a.b.c", Some.class);
@@ -179,13 +179,12 @@ public interface PropertyPath extends Streamable {
 
 	/**
 	 * Extracts the {@link PropertyPath} chain from the given source {@link String} and {@link TypeInformation}. 
- * Uses {@link SimplePropertyPath#SPLITTER} by default and {@link SimplePropertyPath#SPLITTER_FOR_QUOTED} for + * Uses {@code (?:[%s]?([%s]*?[^%s]+))} by default and {@code (?:[%s]?([%s]*?[^%s]+))} for * {@link Pattern#quote(String) quoted} literals. *

* Separate parts of the path may be separated by {@code "."} or by {@code "_"} or by camel case. When the match to - * properties is ambiguous longer property names are preferred. So for "userAddressCity" the interpretation - * "userAddress.city" is preferred over "user.address.city". - *

+ * properties is ambiguous longer property names are preferred. So for {@code userAddressCity} the interpretation + * {@code userAddress.city} is preferred over {@code user.address.city}. * * @param source a String denoting the property path, must not be {@literal null}. * @param type the owning type of the property path, must not be {@literal null}. @@ -197,13 +196,12 @@ public interface PropertyPath extends Streamable { /** * Extracts the {@link PropertyPath} chain from the given source {@link String} and {@link TypeInformation}.
- * Uses {@link SimplePropertyPath#SPLITTER} by default and {@link SimplePropertyPath#SPLITTER_FOR_QUOTED} for + * Uses {@code (?:[%s]?([%s]*?[^%s]+))} by default and {@code (?:[%s]?([%s]*?[^%s]+))} for * {@link Pattern#quote(String) quoted} literals. *

* Separate parts of the path may be separated by {@code "."} or by {@code "_"} or by camel case. When the match to - * properties is ambiguous longer property names are preferred. So for "userAddressCity" the interpretation - * "userAddress.city" is preferred over "user.address.city". - *

+ * properties is ambiguous longer property names are preferred. So for {@code userAddressCity} the interpretation + * {@code userAddress.city} is preferred over {@code user.address.city}. * * @param source a String denoting the property path, must not be {@literal null}. * @param type the owning type of the property path, must not be {@literal null}.