File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/main/java/org/springframework/data/neo4j/core/mapping Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import org .apiguardian .api .API ;
19
19
import org .springframework .data .mapping .PropertyPath ;
20
+ import org .springframework .util .StringUtils ;
20
21
21
22
import java .util .HashSet ;
22
23
import java .util .Map ;
@@ -79,10 +80,17 @@ public boolean contains(String dotPath, Class<?> typeToCheck) {
79
80
return false ;
80
81
}
81
82
82
- Optional <String > first = projectingPropertyPaths .keySet ().stream ().sorted ((o1 , o2 ) -> Integer .compare (o2 .length (), o1 .length ())).filter (dotPath ::contains ).findFirst ();
83
+ // create a sorted list of the deepest paths first
84
+ Optional <String > candidate = projectingPropertyPaths .keySet ().stream ().sorted ((o1 , o2 ) -> {
85
+ int depth1 = StringUtils .countOccurrencesOf (o1 , "." );
86
+ int depth2 = StringUtils .countOccurrencesOf (o2 , "." );
83
87
84
- return projectingPropertyPaths .containsKey (dotPath ) ||
85
- (first .isPresent () && projectingPropertyPaths .get (first .get ()));
88
+ return Integer .compare (depth2 , depth1 );
89
+ })
90
+ .filter (d -> dotPath .contains (d ) && dotPath .startsWith (d )).findFirst ();
91
+
92
+ return projectingPropertyPaths .containsKey (dotPath )
93
+ || (dotPath .contains ("." ) && candidate .isPresent () && projectingPropertyPaths .get (candidate .get ()));
86
94
}
87
95
88
96
@ Override
You can’t perform that action at this time.
0 commit comments