@@ -190,7 +190,7 @@ public boolean isFieldExcluded(String path) {
190
190
191
191
// First we check in the excludes as they are applied last
192
192
for (String exclude : sourceFiltering .excludes ()) {
193
- if (patternMatchesFieldPath ( exclude , path )) {
193
+ if (pathMatchesSourcePattern ( path , exclude )) {
194
194
return true ;
195
195
}
196
196
}
@@ -203,25 +203,26 @@ public boolean isFieldExcluded(String path) {
203
203
}
204
204
205
205
for (String include : sourceFiltering .includes ()) {
206
- if (patternMatchesFieldPath ( include , path )) {
206
+ if (pathMatchesSourcePattern ( path , include )) {
207
207
return false ;
208
208
}
209
209
}
210
210
return true ;
211
211
}
212
212
213
- private static boolean patternMatchesFieldPath (String pattern , String path ) {
214
- if (Regex .isSimpleMatchPattern (pattern )) {
215
- return Regex .simpleMatch (pattern , path );
216
- } else {
217
- if (pattern .equals (path )) {
218
- return true ;
219
- } else {
220
- // include as a concrete field name.
221
- // Let us take "foo" as an example.
222
- // Fields that are "foo.*" will also be included.
223
- return Regex .simpleMatch (pattern + ".*" , path );
224
- }
213
+ private static boolean pathMatchesSourcePattern (String path , String sourcePattern ) {
214
+ if (sourcePattern .equals (path )) {
215
+ return true ;
225
216
}
217
+
218
+ if (Regex .isSimpleMatchPattern (sourcePattern )) {
219
+ return Regex .simpleMatch (sourcePattern , path );
220
+ }
221
+
222
+ // At this stage sourcePattern is a concrete field name and path is not equal to it.
223
+ // We should check if path is a nested field of pattern.
224
+ // Let us take "foo" as an example.
225
+ // Fields that are "foo.*" should also be matched.
226
+ return Regex .simpleMatch (sourcePattern + ".*" , path );
226
227
}
227
228
}
0 commit comments