View Javadoc
1   package org.apache.maven.shared.dependency.tree.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 org.apache.maven.artifact.Artifact;
23  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
24  import org.apache.maven.shared.dependency.tree.DependencyNode;
25  
26  /**
27   * A dependency node filter that delegates to an artifact filter.
28   * 
29   * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
30   * @version $Id: ArtifactDependencyNodeFilter.java 1595642 2014-05-18 17:32:08Z jvanzyl $
31   * @since 1.1
32   */
33  public class ArtifactDependencyNodeFilter
34      implements DependencyNodeFilter
35  {
36      // fields -----------------------------------------------------------------
37  
38      /**
39       * The artifact filter this dependency node filter delegates to.
40       */
41      private final ArtifactFilter filter;
42  
43      // constructors -----------------------------------------------------------
44  
45      /**
46       * Creates a dependency node filter that delegates to the specified artifact filter.
47       * 
48       * @param filter the artifact filter to delegate to
49       */
50      public ArtifactDependencyNodeFilter( ArtifactFilter filter )
51      {
52          this.filter = filter;
53      }
54  
55      // DependencyNodeFilter methods -------------------------------------------
56  
57      /**
58       * {@inheritDoc}
59       */
60      public boolean accept( DependencyNode node )
61      {
62          Artifact artifact = node.getArtifact();
63  
64          return filter.include( artifact );
65      }
66  
67      // public methods ---------------------------------------------------------
68  
69      /**
70       * Gets the artifact filter this dependency node filter delegates to.
71       * 
72       * @return the artifact filter this dependency node filter delegates to
73       */
74      public ArtifactFilter getArtifactFilter()
75      {
76          return filter;
77      }
78  }