Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AndDependencyNodeFilter |
|
| 1.75;1,75 |
1 | package org.apache.maven.shared.dependency.graph.filter; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.util.Arrays; | |
23 | import java.util.Collections; | |
24 | import java.util.List; | |
25 | ||
26 | import org.apache.maven.shared.dependency.graph.DependencyNode; | |
27 | ||
28 | /** | |
29 | * A dependency node filter that logically ANDs together a number of other dependency node filters. | |
30 | * | |
31 | * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a> | |
32 | * @version $Id: AndDependencyNodeFilter.java 1351166 2012-06-17 21:15:54Z hboutemy $ | |
33 | * @since 1.1 | |
34 | */ | |
35 | public class AndDependencyNodeFilter | |
36 | implements DependencyNodeFilter | |
37 | { | |
38 | // fields ----------------------------------------------------------------- | |
39 | ||
40 | /** | |
41 | * The dependency node filters that this filter ANDs together. | |
42 | */ | |
43 | private final List<DependencyNodeFilter> filters; | |
44 | ||
45 | // constructors ----------------------------------------------------------- | |
46 | ||
47 | /** | |
48 | * Creates a dependency node filter that logically ANDs together the two specified dependency node filters. | |
49 | * | |
50 | * @param filter1 | |
51 | * the first dependency node filter to logically AND together | |
52 | * @param filter2 | |
53 | * the second dependency node filter to logically AND together | |
54 | */ | |
55 | public AndDependencyNodeFilter( DependencyNodeFilter filter1, DependencyNodeFilter filter2 ) | |
56 | { | |
57 | 0 | this( Arrays.asList( new DependencyNodeFilter[] { filter1, filter2 } ) ); |
58 | 0 | } |
59 | ||
60 | /** | |
61 | * Creates a dependency node filter that logically ANDs together the specified dependency node filters. | |
62 | * | |
63 | * @param filters | |
64 | * the list of dependency node filters to logically AND together | |
65 | */ | |
66 | public AndDependencyNodeFilter( List<DependencyNodeFilter> filters ) | |
67 | 0 | { |
68 | 0 | this.filters = Collections.unmodifiableList( filters ); |
69 | 0 | } |
70 | ||
71 | // DependencyNodeFilter methods ------------------------------------------- | |
72 | ||
73 | /** | |
74 | * {@inheritDoc} | |
75 | */ | |
76 | public boolean accept( DependencyNode node ) | |
77 | { | |
78 | 0 | for ( DependencyNodeFilter filter : filters ) |
79 | { | |
80 | 0 | if ( !filter.accept( node ) ) |
81 | { | |
82 | 0 | return false; |
83 | } | |
84 | } | |
85 | ||
86 | 0 | return true; |
87 | } | |
88 | ||
89 | // public methods --------------------------------------------------------- | |
90 | ||
91 | /** | |
92 | * Gets the list of dependency node filters that this filter ANDs together. | |
93 | * | |
94 | * @return the dependency node filters that this filter ANDs together | |
95 | */ | |
96 | public List<DependencyNodeFilter> getDependencyNodeFilters() | |
97 | { | |
98 | 0 | return filters; |
99 | } | |
100 | } |