Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
OrGroupMatcher |
|
| 3.7142857142857144;3,714 |
1 | package org.apache.maven.surefire.group.match; | |
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one | |
4 | * or more contributor license agreements. See the NOTICE file | |
5 | * distributed with this work for additional information | |
6 | * regarding copyright ownership. The ASF licenses this file | |
7 | * to you under the Apache License, Version 2.0 (the | |
8 | * "License"); you may not use this file except in compliance | |
9 | * with the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, | |
14 | * software distributed under the License is distributed on an | |
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
16 | * KIND, either express or implied. See the License for the | |
17 | * specific language governing permissions and limitations | |
18 | * under the License. | |
19 | */ | |
20 | ||
21 | import java.util.Collection; | |
22 | ||
23 | public class OrGroupMatcher | |
24 | extends JoinGroupMatcher | |
25 | { | |
26 | ||
27 | public OrGroupMatcher( GroupMatcher... matchers ) | |
28 | 7 | { |
29 | 21 | for ( GroupMatcher matcher : matchers ) |
30 | { | |
31 | 14 | addMatcher( matcher ); |
32 | } | |
33 | 7 | } |
34 | ||
35 | public OrGroupMatcher( Collection<GroupMatcher> matchers ) | |
36 | 0 | { |
37 | 0 | for ( GroupMatcher matcher : matchers ) |
38 | { | |
39 | 0 | addMatcher( matcher ); |
40 | } | |
41 | 0 | } |
42 | ||
43 | public boolean enabled( Class<?>... cats ) | |
44 | { | |
45 | 11 | for ( GroupMatcher matcher : getMatchers() ) |
46 | { | |
47 | 17 | boolean result = matcher.enabled( cats ); |
48 | 17 | if ( result ) |
49 | { | |
50 | 10 | return true; |
51 | } | |
52 | 7 | } |
53 | ||
54 | 1 | return false; |
55 | } | |
56 | ||
57 | public boolean enabled( String... cats ) | |
58 | { | |
59 | 0 | for ( GroupMatcher matcher : getMatchers() ) |
60 | { | |
61 | 0 | boolean result = matcher.enabled( cats ); |
62 | 0 | if ( result ) |
63 | { | |
64 | 0 | return true; |
65 | } | |
66 | 0 | } |
67 | ||
68 | 0 | return false; |
69 | } | |
70 | ||
71 | @Override | |
72 | public String toString() | |
73 | { | |
74 | 0 | StringBuilder sb = new StringBuilder(); |
75 | 0 | for ( GroupMatcher matcher : getMatchers() ) |
76 | { | |
77 | 0 | if ( sb.length() > 0 ) |
78 | { | |
79 | 0 | sb.append( " OR " ); |
80 | } | |
81 | 0 | sb.append( matcher ); |
82 | } | |
83 | ||
84 | 0 | return sb.toString(); |
85 | } | |
86 | ||
87 | @Override | |
88 | public int hashCode() | |
89 | { | |
90 | 0 | final int prime = 37; |
91 | 0 | int result = 1; |
92 | 0 | result = prime * result; |
93 | 0 | for ( GroupMatcher matcher : getMatchers() ) |
94 | { | |
95 | 0 | result += matcher.hashCode(); |
96 | } | |
97 | 0 | return result; |
98 | } | |
99 | ||
100 | @Override | |
101 | public boolean equals( Object obj ) | |
102 | { | |
103 | 0 | if ( this == obj ) |
104 | { | |
105 | 0 | return true; |
106 | } | |
107 | 0 | if ( obj == null ) |
108 | { | |
109 | 0 | return false; |
110 | } | |
111 | 0 | if ( getClass() != obj.getClass() ) |
112 | { | |
113 | 0 | return false; |
114 | } | |
115 | 0 | AndGroupMatcher other = (AndGroupMatcher) obj; |
116 | 0 | if ( !getMatchers().equals( other.getMatchers() ) ) |
117 | { | |
118 | 0 | return false; |
119 | } | |
120 | 0 | return true; |
121 | } | |
122 | } |