1 package org.eclipse.aether.util.graph.transformer;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.eclipse.aether.RepositoryException;
23 import org.eclipse.aether.collection.DependencyGraphTransformationContext;
24 import org.eclipse.aether.collection.DependencyGraphTransformer;
25 import org.eclipse.aether.graph.DependencyNode;
26
27
28
29
30 public final class ChainedDependencyGraphTransformer
31 implements DependencyGraphTransformer
32 {
33
34 private final DependencyGraphTransformer[] transformers;
35
36
37
38
39
40
41 public ChainedDependencyGraphTransformer( DependencyGraphTransformer... transformers )
42 {
43 if ( transformers == null )
44 {
45 this.transformers = new DependencyGraphTransformer[0];
46 }
47 else
48 {
49 this.transformers = transformers;
50 }
51 }
52
53
54
55
56
57
58
59
60
61 public static DependencyGraphTransformer newInstance( DependencyGraphTransformer transformer1,
62 DependencyGraphTransformer transformer2 )
63 {
64 if ( transformer1 == null )
65 {
66 return transformer2;
67 }
68 else if ( transformer2 == null )
69 {
70 return transformer1;
71 }
72 return new ChainedDependencyGraphTransformer( transformer1, transformer2 );
73 }
74
75 public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
76 throws RepositoryException
77 {
78 for ( DependencyGraphTransformer transformer : transformers )
79 {
80 node = transformer.transformGraph( node, context );
81 }
82 return node;
83 }
84
85 }