65
65
*/
66
66
public class QuerydslBindings {
67
67
68
+ // pathSpecs key format: <class.simpleName>.<pathInformation.toDotPath>
68
69
private final Map <String , PathAndBinding <?, ?>> pathSpecs ;
69
70
private final Map <Class <?>, PathAndBinding <?, ?>> typeSpecs ;
70
71
private final Set <String > allowList ;
@@ -203,7 +204,7 @@ public <S extends Path<? extends T>, T> Optional<MultiValueBinding<S, T>> getBin
203
204
204
205
Assert .notNull (path , "PropertyPath must not be null!" );
205
206
206
- PathAndBinding <S , T > pathAndBinding = (PathAndBinding <S , T >) pathSpecs .get (path . toDotPath ( ));
207
+ PathAndBinding <S , T > pathAndBinding = (PathAndBinding <S , T >) pathSpecs .get (createKey ( path ));
207
208
208
209
if (pathAndBinding != null ) {
209
210
@@ -229,7 +230,7 @@ Optional<Path<?>> getExistingPath(PathInformation path) {
229
230
230
231
Assert .notNull (path , "PropertyPath must not be null!" );
231
232
232
- return Optional .ofNullable (pathSpecs .get (path . toDotPath ( ))).flatMap (PathAndBinding ::getPath );
233
+ return Optional .ofNullable (pathSpecs .get (createKey ( path ))).flatMap (PathAndBinding ::getPath );
233
234
}
234
235
235
236
/**
@@ -249,6 +250,15 @@ PathInformation getPropertyPath(String path, TypeInformation<?> type) {
249
250
return null ;
250
251
}
251
252
253
+ // fully-qualified path lookup
254
+ String key = createKey (type , path );
255
+ if (pathSpecs .containsKey (key )) {
256
+ return pathSpecs .get (key ).getPath ()//
257
+ .map (QuerydslPathInformation ::of )//
258
+ .orElse (null );
259
+ }
260
+
261
+ // alias lookup
252
262
if (pathSpecs .containsKey (path )) {
253
263
return pathSpecs .get (path ).getPath ()//
254
264
.map (QuerydslPathInformation ::of )//
@@ -263,6 +273,28 @@ PathInformation getPropertyPath(String path, TypeInformation<?> type) {
263
273
}
264
274
}
265
275
276
+ /**
277
+ * Returns the property path key for the given {@link Path}.
278
+ *
279
+ * @param path can be {@literal null}.
280
+ * @return
281
+ */
282
+ private static String createKey (Optional <Path <?>> path ) {
283
+ return path .map (QuerydslPathInformation ::of ).map (QuerydslBindings ::createKey ).orElse ("" );
284
+ }
285
+
286
+ private static String createKey (PathInformation path ) {
287
+ return createKey (path .getRootParentType (), path .toDotPath ());
288
+ }
289
+
290
+ private static String createKey (TypeInformation <?> type , String path ) {
291
+ return createKey (type .getType (), path );
292
+ }
293
+
294
+ private static String createKey (Class <?> type , String path ) {
295
+ return type .getSimpleName () + "." + path ;
296
+ }
297
+
266
298
/**
267
299
* Checks if a given {@link PropertyPath} should be visible for binding values.
268
300
*
@@ -385,7 +417,7 @@ public void all(MultiValueBinding<P, T> binding) {
385
417
}
386
418
387
419
protected void registerBinding (PathAndBinding <P , T > binding ) {
388
- QuerydslBindings .this .pathSpecs .put (toDotPath (binding .getPath ()), binding );
420
+ QuerydslBindings .this .pathSpecs .put (createKey (binding .getPath ()), binding );
389
421
}
390
422
}
391
423
@@ -455,10 +487,12 @@ protected void registerBinding(PathAndBinding<P, T> binding) {
455
487
456
488
super .registerBinding (binding );
457
489
490
+ String dotPath = toDotPath (binding .getPath ());
491
+
458
492
if (alias != null ) {
459
493
QuerydslBindings .this .pathSpecs .put (alias , binding );
460
494
QuerydslBindings .this .aliases .add (alias );
461
- QuerydslBindings .this .denyList .add (toDotPath ( binding . getPath ()) );
495
+ QuerydslBindings .this .denyList .add (dotPath );
462
496
}
463
497
}
464
498
}
0 commit comments