@@ -108,7 +108,15 @@ public TypeInformation<?> getOwningType() {
108
108
}
109
109
110
110
/**
111
- * Returns the name of the {@link PropertyPath}.
111
+ * Returns the first part of the {@link PropertyPath}.
112
+ *
113
+ * <pre>
114
+ * {@code
115
+ * PropertyPath.from("a.b.c", Some.class).getSegment();
116
+ * }
117
+ * </pre>
118
+ *
119
+ * will result in {@code "a"}
112
120
*
113
121
* @return the name will never be {@literal null}.
114
122
*/
@@ -156,7 +164,15 @@ public TypeInformation<?> getTypeInformation() {
156
164
}
157
165
158
166
/**
159
- * Returns the next nested {@link PropertyPath}.
167
+ * Returns the {@link PropertyPath} path that results from removing the first element of the current one.
168
+ *
169
+ * <pre>
170
+ * {@code
171
+ * System.out.println(PropertyPath.from("a.b.c", Some.class).next().toDotPath());
172
+ * }
173
+ * </pre>
174
+ *
175
+ * Will result in the output: {@code b.c}
160
176
*
161
177
* @return the next nested {@link PropertyPath} or {@literal null} if no nested {@link PropertyPath} available.
162
178
* @see #hasNext()
@@ -214,6 +230,29 @@ public PropertyPath nested(String path) {
214
230
return PropertyPath .from (lookup , owningType );
215
231
}
216
232
233
+ /**
234
+ * Returns an {@link Iterator<PropertyPath>} that iterates over all the partial property paths with the same leaf type
235
+ * but decreasing length.
236
+ *
237
+ * <pre>
238
+ * {@code
239
+ * PropertyPath propertyPath = PropertyPath.from("a.b.c", Some.class);
240
+ * for (p : propertyPath.iterator()) {
241
+ * System.out.println(p.toDotPath());
242
+ * };
243
+ * }
244
+ * </pre>
245
+ *
246
+ * Results in the output:
247
+ *
248
+ * <pre>
249
+ * {@code
250
+ * a.b.c
251
+ * b.c
252
+ * c
253
+ * }
254
+ * </pre>
255
+ */
217
256
public Iterator <PropertyPath > iterator () {
218
257
219
258
return new Iterator <PropertyPath >() {
@@ -289,11 +328,18 @@ private PropertyPath requiredNext() {
289
328
}
290
329
291
330
/**
292
- * Extracts the {@link PropertyPath} chain from the given source {@link String} and type.
331
+ * Extracts the {@link PropertyPath} chain from the given source {@link String} and {@link TypeInformation}. <br />
332
+ * Uses {@link #SPLITTER} by default and {@link #SPLITTER_FOR_QUOTED} for {@link Pattern#quote(String) quoted}
333
+ * literals.
334
+ * <p>
335
+ * Separate parts of the path may be separated by {@code "."} or by {@code "_"} or by camel case. When the match to
336
+ * properties is ambiguous longer property names are preferred. So for "userAddressCity" the interpretation
337
+ * "userAddress.city" is preferred over "user.address.city".
338
+ * </p>
293
339
*
294
- * @param source
295
- * @param type
296
- * @return
340
+ * @param source a String denoting the property path. Must not be {@literal null}.
341
+ * @param type the owning type of the property path. Must not be {@literal null}.
342
+ * @return a new {@link PropertyPath} guaranteed to be not {@literal null}.
297
343
*/
298
344
public static PropertyPath from (String source , Class <?> type ) {
299
345
return from (source , TypeInformation .of (type ));
@@ -303,10 +349,15 @@ public static PropertyPath from(String source, Class<?> type) {
303
349
* Extracts the {@link PropertyPath} chain from the given source {@link String} and {@link TypeInformation}. <br />
304
350
* Uses {@link #SPLITTER} by default and {@link #SPLITTER_FOR_QUOTED} for {@link Pattern#quote(String) quoted}
305
351
* literals.
352
+ * <p>
353
+ * Separate parts of the path may be separated by {@code "."} or by {@code "_"} or by camel case. When the match to
354
+ * properties is ambiguous longer property names are preferred. So for "userAddressCity" the interpretation
355
+ * "userAddress.city" is preferred over "user.address.city".
356
+ * </p>
306
357
*
307
- * @param source must not be {@literal null}.
308
- * @param type
309
- * @return
358
+ * @param source a String denoting the property path. Must not be {@literal null}.
359
+ * @param type the owning type of the property path. Must not be {@literal null}.
360
+ * @return a new {@link PropertyPath} guaranteed to be not {@literal null}.
310
361
*/
311
362
public static PropertyPath from (String source , TypeInformation <?> type ) {
312
363
0 commit comments