1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.artifact.resolver.filter;
20
21 import java.util.Collection;
22 import java.util.HashSet;
23 import java.util.Set;
24
25
26
27
28
29
30
31
32 public class CumulativeScopeArtifactFilter extends AbstractScopeArtifactFilter {
33
34 private Set<String> scopes;
35
36
37
38
39
40
41 public CumulativeScopeArtifactFilter(Collection<String> scopes) {
42 this.scopes = new HashSet<>();
43
44 addScopes(scopes);
45 }
46
47
48
49
50
51
52 public CumulativeScopeArtifactFilter(CumulativeScopeArtifactFilter... filters) {
53 this.scopes = new HashSet<>();
54
55 if (filters != null) {
56 for (CumulativeScopeArtifactFilter filter : filters) {
57 addScopes(filter.getScopes());
58 }
59 }
60 }
61
62 private void addScopes(Collection<String> scopes) {
63 if (scopes != null) {
64 for (String scope : scopes) {
65 addScope(scope);
66 }
67 }
68 }
69
70 private void addScope(String scope) {
71 this.scopes.add(scope);
72
73 addScopeInternal(scope);
74 }
75
76 public Set<String> getScopes() {
77 return scopes;
78 }
79
80 @Override
81 public int hashCode() {
82 int hash = 17;
83
84 hash = hash * 31 + scopes.hashCode();
85
86 return hash;
87 }
88
89 @Override
90 public boolean equals(Object obj) {
91 if (this == obj) {
92 return true;
93 }
94
95 if (!(obj instanceof CumulativeScopeArtifactFilter)) {
96 return false;
97 }
98
99 CumulativeScopeArtifactFilter that = (CumulativeScopeArtifactFilter) obj;
100
101 return scopes.equals(that.scopes);
102 }
103 }