@@ -190,7 +190,7 @@ public boolean isFieldExcluded(String path) {
190190
191191 // First we check in the excludes as they are applied last
192192 for (String exclude : sourceFiltering .excludes ()) {
193- if (patternMatchesFieldPath ( exclude , path )) {
193+ if (pathMatchesSourcePattern ( path , exclude )) {
194194 return true ;
195195 }
196196 }
@@ -203,25 +203,26 @@ public boolean isFieldExcluded(String path) {
203203 }
204204
205205 for (String include : sourceFiltering .includes ()) {
206- if (patternMatchesFieldPath ( include , path )) {
206+ if (pathMatchesSourcePattern ( path , include )) {
207207 return false ;
208208 }
209209 }
210210 return true ;
211211 }
212212
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 ;
225216 }
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 );
226227 }
227228}
0 commit comments