View Javadoc
1   /*
2    * (C) Copyright 2006-2014 Nuxeo SA (http://nuxeo.com/) and contributors.
3    *
4    * All rights reserved. This program and the accompanying materials
5    * are made available under the terms of the GNU Lesser General Public License
6    * (LGPL) version 2.1 which accompanies this distribution, and is available at
7    * http://www.gnu.org/licenses/lgpl-21.html
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * Contributors:
15   *     bstefanescu, slacoin, jcarsique
16   */
17  package org.nuxeo.build.maven.filter;
18  
19  import java.util.List;
20  
21  import org.apache.maven.artifact.Artifact;
22  import org.apache.tools.ant.Project;
23  import org.eclipse.aether.graph.DependencyNode;
24  import org.nuxeo.build.ant.AntClient;
25  
26  /**
27   * TODO NXBT-258
28   */
29  public class AndFilter extends CompositeFilter {
30  
31      public AndFilter() {
32      }
33  
34      public AndFilter(List<Filter> filters) {
35          super(filters);
36      }
37  
38      @Override
39      public boolean accept(Artifact artifact) {
40          for (Filter filter : filters) {
41              if (!filter.accept(artifact)) {
42                  return result(false, artifact.toString());
43              }
44          }
45          return result(true, artifact.toString());
46      }
47  
48      @Override
49      public String toString() {
50          return super.toString() + " => ";
51      }
52  
53      @Override
54      public boolean accept(DependencyNode node, List<DependencyNode> parents) {
55          AntClient.getInstance().log("Filtering - " + super.toString() + "...",
56                  Project.MSG_DEBUG);
57          for (Filter filter : filters) {
58              if (!filter.accept(node, parents)) {
59                  return result(false, node.toString());
60              }
61          }
62          return result(true, node.toString());
63      }
64  
65  }