1 package org.eclipse.aether.util.graph.selector;
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.collection.DependencyCollectionContext;
23 import org.eclipse.aether.collection.DependencySelector;
24 import org.eclipse.aether.graph.Dependency;
25
26 import static java.util.Objects.requireNonNull;
27
28
29
30
31 public final class StaticDependencySelector
32 implements DependencySelector
33 {
34
35 private final boolean select;
36
37
38
39
40
41
42 public StaticDependencySelector( boolean select )
43 {
44 this.select = select;
45 }
46
47 public boolean selectDependency( Dependency dependency )
48 {
49 requireNonNull( dependency, "dependency cannot be null" );
50 return select;
51 }
52
53 public DependencySelector deriveChildSelector( DependencyCollectionContext context )
54 {
55 requireNonNull( context, "context cannot be null" );
56 return this;
57 }
58
59 @Override
60 public boolean equals( Object obj )
61 {
62 if ( this == obj )
63 {
64 return true;
65 }
66 else if ( null == obj || !getClass().equals( obj.getClass() ) )
67 {
68 return false;
69 }
70
71 StaticDependencySelector that = (StaticDependencySelector) obj;
72 return select == that.select;
73 }
74
75 @Override
76 public int hashCode()
77 {
78 int hash = getClass().hashCode();
79 hash = hash * 31 + ( select ? 1 : 0 );
80 return hash;
81 }
82
83 @Override
84 public String toString()
85 {
86 return String.format( "%s(%s)", this.getClass().getSimpleName(), this.select ? "Select all" : "Exclude all" );
87 }
88
89 }