1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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.eclipse.aether.graph.DependencyNode;
23
24
25
26
27 public class ArtifactIdFilter extends AbstractFilter {
28
29 protected SegmentMatch matcher;
30
31 public ArtifactIdFilter(String pattern) {
32 this(SegmentMatch.parse(pattern));
33 }
34
35 public ArtifactIdFilter(SegmentMatch matcher) {
36 this.matcher = matcher;
37 }
38
39 @Override
40 public boolean accept(Artifact artifact) {
41 return result(matcher.match(artifact.getArtifactId()),
42 artifact.toString());
43 }
44
45 @Override
46 public String toString() {
47 return super.toString() + " [" + matcher + "]";
48 }
49
50 @Override
51 public boolean accept(DependencyNode node, List<DependencyNode> parents) {
52 org.eclipse.aether.artifact.Artifact artifact = node.getArtifact();
53 if (artifact == null) {
54 return result(matcher == SegmentMatch.ANY, node.toString());
55 }
56 return result(matcher.match(artifact.getArtifactId()), node.toString());
57 }
58
59 }