|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
CompositeFilter.java | 100% | 100% | 100% | 100% |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.hivemind.methodmatch; | |
16 | ||
17 | import java.util.Iterator; | |
18 | import java.util.List; | |
19 | ||
20 | import org.apache.hivemind.service.MethodSignature; | |
21 | ||
22 | /** | |
23 | * Runs a suite of {@link org.apache.hivemind.methodmatch.MethodFilter}s, returning | |
24 | * true only if each filter does. The tests short-circuit with the first filter | |
25 | * to return false. | |
26 | * | |
27 | * @author Howard Lewis Ship | |
28 | */ | |
29 | public class CompositeFilter extends MethodFilter | |
30 | { | |
31 | private List _filters; | |
32 | ||
33 | /** | |
34 | * Creates a new composite filter; the list passed in is <em>retained not copied</em> | |
35 | * and should not be changed futher by the caller. | |
36 | * | |
37 | * @param filters {@link List} of {@link MethodFilter}. | |
38 | */ | |
39 | 4 | public CompositeFilter(List filters) |
40 | { | |
41 | 4 | _filters = filters; |
42 | } | |
43 | ||
44 | 6 | public boolean matchMethod(MethodSignature sig) |
45 | { | |
46 | 6 | Iterator i = _filters.iterator(); |
47 | 6 | while (i.hasNext()) |
48 | { | |
49 | 11 | MethodFilter mf = (MethodFilter) i.next(); |
50 | ||
51 | 11 | if (!mf.matchMethod(sig)) |
52 | 3 | return false; |
53 | } | |
54 | ||
55 | // All matches! | |
56 | ||
57 | 3 | return true; |
58 | } | |
59 | ||
60 | } |
|