Skip to content

Commit ef595f0

Browse files
committed
Polishing.
Refine type naming.
1 parent fc05f18 commit ef595f0

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

src/main/java/org/springframework/data/core/SerializableLambdaReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public MemberDescriptor read(Object lambdaObject) {
151151
}
152152

153153
if (captured != null //
154-
&& captured instanceof KPropertyReferenceImpl<?, ?> propRef) {
154+
&& captured instanceof KPropertyPath<?, ?> propRef) {
155155
return KPropertyPathDescriptor.create(propRef);
156156
}
157157
}

src/main/java/org/springframework/data/core/TypedPropertyPaths.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static <P, T> TypedPropertyPath<T, P> of(PropertyReference<T, P> lambda)
129129

130130
if (KotlinDetector.isKotlinReflectPresent()) {
131131
if (metadata instanceof KPropertyPathMetadata kMetadata
132-
&& kMetadata.getProperty() instanceof KPropertyReferenceImpl<?, ?> ref) {
132+
&& kMetadata.getProperty() instanceof KPropertyPath<?, ?> ref) {
133133
return KotlinDelegate.of(ref);
134134
}
135135
}
@@ -145,7 +145,7 @@ static class KotlinDelegate {
145145
@SuppressWarnings({ "rawtypes", "unchecked" })
146146
public static <T, P> TypedPropertyPath<T, P> of(Object property) {
147147

148-
if (property instanceof KPropertyReferenceImpl paths) {
148+
if (property instanceof KPropertyPath paths) {
149149

150150
TypedPropertyPath parent = of(paths.getProperty());
151151
TypedPropertyPath child = of(paths.getLeaf());

src/main/kotlin/org/springframework/data/core/KPropertyExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fun <T : Any, P> KProperty1<T, P>.toPath(): TypedPropertyPath<T, P> =
3939
KTypedPropertyPath.of(this)
4040

4141
/**
42-
* Builds [KPropertyReferenceImpl] from Property References.
42+
* Builds [KPropertyPath] from Property References.
4343
* Refer to a nested property in an embeddable or association.
4444
*
4545
* For example, referring to the field "author.name":
@@ -56,7 +56,7 @@ operator fun <T, M, P> KProperty1<T, M?>.div(other: KProperty1<M, P?>): KPropert
5656
KSinglePropertyReference(this, other) as KProperty1<T, P>
5757

5858
/**
59-
* Builds [KPropertyReferenceImpl] from Property References.
59+
* Builds [KPropertyPath] from Property References.
6060
* Refer to a nested property in an embeddable or association.
6161
*
6262
* Note, that this function is different from [div] above in the

src/main/kotlin/org/springframework/data/core/KPropertyReferenceImpl.kt renamed to src/main/kotlin/org/springframework/data/core/KPropertyPath.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ import kotlin.reflect.KProperty1
2828
* @author Yoann de Martino
2929
* @since 4.1
3030
*/
31-
internal interface KPropertyReferenceImpl<T, out P> : KProperty1<T, P> {
31+
internal interface KPropertyPath<T, out P> : KProperty1<T, P> {
3232
val property: KProperty1<T, *>
3333
val leaf: KProperty1<*, P>
3434
}
3535

3636
internal class KSinglePropertyReference<T, M, out P>(
3737
val parent: KProperty1<T, M?>,
3838
val child: KProperty1<M, P>
39-
) : KProperty1<T, P> by child as KProperty1<T, P>, KPropertyReferenceImpl<T, P> {
39+
) : KProperty1<T, P> by child as KProperty1<T, P>, KPropertyPath<T, P> {
4040

4141
override fun get(receiver: T): P {
4242

@@ -71,7 +71,7 @@ internal class KSinglePropertyReference<T, M, out P>(
7171
internal class KIterablePropertyReference<T, M, out P>(
7272
val parent: KProperty1<T, Iterable<M?>?>,
7373
val child: KProperty1<M, P>
74-
) : KProperty1<T, P> by child as KProperty1<T, P>, KPropertyReferenceImpl<T, P> {
74+
) : KProperty1<T, P> by child as KProperty1<T, P>, KPropertyPath<T, P> {
7575

7676
override fun get(receiver: T): P {
7777
throw UnsupportedOperationException("Collection retrieval not supported")
@@ -95,7 +95,7 @@ internal class KIterablePropertyReference<T, M, out P>(
9595
*/
9696
internal fun asString(property: KProperty<*>): String {
9797
return when (property) {
98-
is KPropertyReferenceImpl<*, *> ->
98+
is KPropertyPath<*, *> ->
9999
"${asString(property.property)}.${property.leaf.name}"
100100

101101
else -> property.name

src/main/kotlin/org/springframework/data/core/PropertyReferenceExtensions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class KPropertyReference {
7979
*/
8080
fun <T, P> of(property: KProperty<P?>): PropertyReference<T, P> {
8181

82-
if (property is KPropertyReferenceImpl<*, *>) {
83-
throw IllegalArgumentException("Property reference ${property.name} must not be a property path")
82+
if (property is KPropertyPath<*, *>) {
83+
throw IllegalArgumentException("Property reference '${property.toDotPath()}' must be a single property reference, not a property path")
8484
}
8585

8686
if (property is KProperty1<*, *>) {
@@ -97,7 +97,7 @@ class KPropertyReference {
9797
return PropertyReferences.ResolvedKPropertyReference(metadata)
9898
}
9999

100-
throw IllegalArgumentException("Property ${property.name} is not a KProperty")
100+
throw IllegalArgumentException("Property '${property.name}' is not a KProperty")
101101
}
102102

103103
}

src/main/kotlin/org/springframework/data/core/TypedPropertyPathExtensions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class KTypedPropertyPath {
7777
*/
7878
fun <T, P> of(property: KProperty<P?>): TypedPropertyPath<T, P> {
7979

80-
if (property is KPropertyReferenceImpl<*, *>) {
80+
if (property is KPropertyPath<*, *>) {
8181

82-
val paths = property as KPropertyReferenceImpl<*, *>
82+
val paths = property as KPropertyPath<*, *>
8383

8484
val parent = of<Any, Any>(paths.property)
8585
val child = of<Any, Any>(paths.leaf)
@@ -104,7 +104,7 @@ class KTypedPropertyPath {
104104
return TypedPropertyPaths.ResolvedKPropertyPath(metadata)
105105
}
106106

107-
throw IllegalArgumentException("Property ${property.name} is not a KProperty")
107+
throw IllegalArgumentException("Property '${property.name}' is not a KProperty")
108108
}
109109

110110
}

src/test/kotlin/org/springframework/data/core/KTypedPropertyPathUnitTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.junit.jupiter.params.provider.MethodSource
99
import java.util.stream.Stream
1010

1111
/**
12-
* Unit tests for [KPropertyReferenceImpl] and related functionality.
12+
* Unit tests for [KPropertyPath] and related functionality.
1313
*
1414
* @author Mark Paluch
1515
*/

0 commit comments

Comments
 (0)