diff --git a/src/main/java/org/springframework/data/mapping/TypedPropertyPath.java b/src/main/java/org/springframework/data/mapping/TypedPropertyPath.java index de570fb0e..36df105ac 100644 --- a/src/main/java/org/springframework/data/mapping/TypedPropertyPath.java +++ b/src/main/java/org/springframework/data/mapping/TypedPropertyPath.java @@ -97,7 +97,7 @@ public interface TypedPropertyPath extends PropertyPath, Serializable { @Override default String getSegment() { - return TypedPropertyPaths.getPropertyPathInformation(this).property().getName(); + return TypedPropertyPaths.getPropertyPathInformation(this).property(); } @Override diff --git a/src/main/java/org/springframework/data/mapping/TypedPropertyPaths.java b/src/main/java/org/springframework/data/mapping/TypedPropertyPaths.java index 30852793a..55d2f3f2a 100644 --- a/src/main/java/org/springframework/data/mapping/TypedPropertyPaths.java +++ b/src/main/java/org/springframework/data/mapping/TypedPropertyPaths.java @@ -15,7 +15,6 @@ */ package org.springframework.data.mapping; -import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.IOException; @@ -37,6 +36,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.jspecify.annotations.Nullable; + import org.springframework.asm.ClassReader; import org.springframework.asm.ClassVisitor; import org.springframework.asm.Label; @@ -103,12 +103,12 @@ class TypedPropertyPaths { /** * Value object holding information about a property path segment. - * + * * @param owner * @param propertyType * @param property */ - record PropertyPathInformation(TypeInformation owner, TypeInformation propertyType, Property property) { + record PropertyPathInformation(TypeInformation owner, TypeInformation propertyType, String property) { public static PropertyPathInformation ofInvokeVirtual(ClassLoader classLoader, SerializedLambda lambda) throws ClassNotFoundException { @@ -142,13 +142,8 @@ class TypedPropertyPaths { TypeInformation fallback = TypeInformation.of(owner).getProperty(propertyName); if (fallback != null) { - try { return new PropertyPathInformation(TypeInformation.of(owner), fallback, - Property.of(TypeInformation.of(owner), new PropertyDescriptor(propertyName, method, null))); - } catch (IntrospectionException e) { - throw new IllegalArgumentException( - "Cannot find PropertyDescriptor from method %s.%s".formatted(owner.getName(), methodName), e); - } + propertyName); } throw new IllegalArgumentException( @@ -157,7 +152,7 @@ class TypedPropertyPaths { return new PropertyPathInformation(TypeInformation.of(owner), TypeInformation.of(ResolvableType.forMethodReturnType(method, owner)), - Property.of(TypeInformation.of(owner), descriptor)); + descriptor.getName()); } public static PropertyPathInformation ofFieldAccess(ClassLoader classLoader, Type ownerType, String name, @@ -177,7 +172,7 @@ class TypedPropertyPaths { } return new PropertyPathInformation(TypeInformation.of(owner), - TypeInformation.of(ResolvableType.forField(field, owner)), Property.of(TypeInformation.of(owner), field)); + TypeInformation.of(ResolvableType.forField(field, owner)), field.getName()); } } @@ -296,7 +291,7 @@ class TypedPropertyPaths { @Override public String getSegment() { - return information.property().getName(); + return information.property(); } @Override @@ -309,6 +304,7 @@ class TypedPropertyPaths { return list.iterator(); } + @Override public Stream stream() { return list.stream(); }