1 package org.apache.maven.plugin.surefire.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.HashSet;
23 import java.util.Set;
24
25 import javax.annotation.Nullable;
26
27 import org.apache.maven.shared.utils.io.SelectorUtils;
28
29 import static org.apache.maven.plugin.surefire.util.ScannerUtil.convertSlashToSystemFileSeparator;
30
31 public class SpecificFileFilter
32 {
33
34 private Set<String> names;
35
36 public SpecificFileFilter( @Nullable String[] classNames )
37 {
38 if ( classNames != null && classNames.length > 0 )
39 {
40 this.names = new HashSet<String>();
41 for ( String name : classNames )
42 {
43 names.add( convertSlashToSystemFileSeparator( name ) );
44 }
45 }
46 }
47
48 public boolean accept( @Nullable String resourceName )
49 {
50
51 if ( names != null && !names.isEmpty() )
52 {
53 for ( String pattern : names )
54 {
55
56
57 if ( SelectorUtils.matchPath( pattern, resourceName, true ) )
58 {
59 return true;
60 }
61 }
62 return false;
63 }
64 return true;
65 }
66
67 }