Skip to content

Commit d9a14b0

Browse files
committed
Fixed incorrect docs PersistentPropertyPath and optimized sublist
1 parent 6328b4c commit d9a14b0

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

src/main/java/org/springframework/data/mapping/PersistentPropertyPath.java

+2-16
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ public interface PersistentPropertyPath<P extends PersistentProperty<P>> extends
2929

3030
/**
3131
* Returns the dot based path notation using {@link PersistentProperty#getName()}.
32-
*
33-
* @return
3432
*/
3533
@Nullable
3634
String toDotPath();
@@ -40,7 +38,6 @@ public interface PersistentPropertyPath<P extends PersistentProperty<P>> extends
4038
* {@link PersistentProperty}s to path segments.
4139
*
4240
* @param converter must not be {@literal null}.
43-
* @return
4441
*/
4542
@Nullable
4643
String toDotPath(Converter<? super P, String> converter);
@@ -49,7 +46,6 @@ public interface PersistentPropertyPath<P extends PersistentProperty<P>> extends
4946
* Returns a {@link String} path with the given delimiter based on the {@link PersistentProperty#getName()}.
5047
*
5148
* @param delimiter must not be {@literal null}.
52-
* @return
5349
*/
5450
@Nullable
5551
String toPath(String delimiter);
@@ -60,7 +56,6 @@ public interface PersistentPropertyPath<P extends PersistentProperty<P>> extends
6056
*
6157
* @param delimiter must not be {@literal null}.
6258
* @param converter must not be {@literal null}.
63-
* @return
6459
*/
6560
@Nullable
6661
String toPath(String delimiter, Converter<? super P, String> converter);
@@ -70,7 +65,6 @@ public interface PersistentPropertyPath<P extends PersistentProperty<P>> extends
7065
* {@link PersistentProperty} for {@code bar}. For a simple {@code foo} it returns {@link PersistentProperty} for
7166
* {@code foo}.
7267
*
73-
* @return
7468
*/
7569
@Nullable
7670
P getLeafProperty();
@@ -90,44 +84,36 @@ default P getRequiredLeafProperty() {
9084
* Returns the first property in the {@link PersistentPropertyPath}. So for {@code foo.bar} it will return the
9185
* {@link PersistentProperty} for {@code foo}. For a simple {@code foo} it returns {@link PersistentProperty} for
9286
* {@code foo}.
93-
*
94-
* @return
9587
*/
9688
@Nullable
9789
P getBaseProperty();
9890

9991
/**
10092
* Returns whether the given {@link PersistentPropertyPath} is a base path of the current one. This means that the
101-
* current {@link PersistentPropertyPath} is basically an extension of the given one.
93+
* given {@link PersistentPropertyPath} is basically an extension of this {@link PersistentPropertyPath}.
10294
*
10395
* @param path must not be {@literal null}.
104-
* @return
10596
*/
10697
boolean isBasePathOf(PersistentPropertyPath<P> path);
10798

10899
/**
109100
* Returns the sub-path of the current one as if it was based on the given base path. So for a current path
110101
* {@code foo.bar} and a given base {@code foo} it would return {@code bar}. If the given path is not a base of the
111-
* the current one the current {@link PersistentPropertyPath} will be returned as is.
102+
* current one the current {@link PersistentPropertyPath} will be returned as is.
112103
*
113104
* @param base must not be {@literal null}.
114-
* @return
115105
*/
116106
PersistentPropertyPath<P> getExtensionForBaseOf(PersistentPropertyPath<P> base);
117107

118108
/**
119109
* Returns the parent path of the current {@link PersistentPropertyPath}, i.e. the path without the leaf property.
120110
* This happens up to the base property. So for a direct property reference calling this method will result in
121111
* returning the property.
122-
*
123-
* @return
124112
*/
125113
PersistentPropertyPath<P> getParentPath();
126114

127115
/**
128116
* Returns the length of the {@link PersistentPropertyPath}.
129-
*
130-
* @return
131117
*/
132118
int getLength();
133119
}

src/main/java/org/springframework/data/mapping/context/DefaultPersistentPropertyPath.java

+2-13
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
class DefaultPersistentPropertyPath<P extends PersistentProperty<P>> implements PersistentPropertyPath<P> {
4040

41-
private static final Converter<PersistentProperty<?>, String> DEFAULT_CONVERTER = (source) -> source.getName();
41+
private static final Converter<PersistentProperty<?>, String> DEFAULT_CONVERTER = PersistentProperty::getName;
4242
private static final String DEFAULT_DELIMITER = ".";
4343

4444
private final List<P> properties;
@@ -158,18 +158,7 @@ public PersistentPropertyPath<P> getExtensionForBaseOf(PersistentPropertyPath<P>
158158
return this;
159159
}
160160

161-
List<P> result = new ArrayList<>();
162-
Iterator<P> iterator = iterator();
163-
164-
for (int i = 0; i < base.getLength(); i++) {
165-
iterator.next();
166-
}
167-
168-
while (iterator.hasNext()) {
169-
result.add(iterator.next());
170-
}
171-
172-
return new DefaultPersistentPropertyPath<>(result);
161+
return new DefaultPersistentPropertyPath<>(properties.subList(base.getLength(), properties.size()));
173162
}
174163

175164
public PersistentPropertyPath<P> getParentPath() {

0 commit comments

Comments
 (0)