1 package org.apache.maven.surefire.group.match;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Collection;
23
24
25
26
27
28 public class OrGroupMatcher
29 extends JoinGroupMatcher
30 {
31
32 public OrGroupMatcher( GroupMatcher... matchers )
33 {
34 for ( GroupMatcher matcher : matchers )
35 {
36 addMatcher( matcher );
37 }
38 }
39
40 public OrGroupMatcher( Collection<GroupMatcher> matchers )
41 {
42 for ( GroupMatcher matcher : matchers )
43 {
44 addMatcher( matcher );
45 }
46 }
47
48 public boolean enabled( Class<?>... cats )
49 {
50 for ( GroupMatcher matcher : getMatchers() )
51 {
52 boolean result = matcher.enabled( cats );
53 if ( result )
54 {
55 return true;
56 }
57 }
58
59 return false;
60 }
61
62 public boolean enabled( String... cats )
63 {
64 for ( GroupMatcher matcher : getMatchers() )
65 {
66 boolean result = matcher.enabled( cats );
67 if ( result )
68 {
69 return true;
70 }
71 }
72
73 return false;
74 }
75
76 @Override
77 public String toString()
78 {
79 StringBuilder sb = new StringBuilder();
80 for ( GroupMatcher matcher : getMatchers() )
81 {
82 if ( sb.length() > 0 )
83 {
84 sb.append( " OR " );
85 }
86 sb.append( matcher );
87 }
88
89 return sb.toString();
90 }
91
92 @Override
93 public int hashCode()
94 {
95 final int prime = 37;
96 int result = 1;
97 result = prime * result;
98 for ( GroupMatcher matcher : getMatchers() )
99 {
100 result += matcher.hashCode();
101 }
102 return result;
103 }
104
105 @Override
106 public boolean equals( Object obj )
107 {
108 if ( this == obj )
109 {
110 return true;
111 }
112 if ( obj == null )
113 {
114 return false;
115 }
116 if ( getClass() != obj.getClass() )
117 {
118 return false;
119 }
120 AndGroupMatcher other = (AndGroupMatcher) obj;
121 return getMatchers().equals( other.getMatchers() );
122 }
123 }