1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl.collect;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.Iterator;
24 import java.util.List;
25
26 import org.eclipse.aether.RepositorySystemSession;
27 import org.eclipse.aether.collection.VersionFilter;
28 import org.eclipse.aether.graph.Dependency;
29 import org.eclipse.aether.repository.ArtifactRepository;
30 import org.eclipse.aether.repository.RemoteRepository;
31 import org.eclipse.aether.resolution.VersionRangeResult;
32 import org.eclipse.aether.version.Version;
33 import org.eclipse.aether.version.VersionConstraint;
34
35
36
37
38
39 public final class DefaultVersionFilterContext implements VersionFilter.VersionFilterContext {
40 private final RepositorySystemSession session;
41
42 private Dependency dependency;
43
44 VersionRangeResult result;
45
46 private List<Version> versions;
47
48 public DefaultVersionFilterContext(RepositorySystemSession session) {
49 this.session = session;
50 }
51
52 public void set(Dependency dependency, VersionRangeResult result) {
53 this.dependency = dependency;
54 this.result = result;
55 this.versions = new ArrayList<>(result.getVersions());
56 }
57
58 public List<Version> get() {
59 return new ArrayList<>(versions);
60 }
61
62 @Override
63 public RepositorySystemSession getSession() {
64 return session;
65 }
66
67 @Override
68 public Dependency getDependency() {
69 return dependency;
70 }
71
72 @Override
73 public VersionConstraint getVersionConstraint() {
74 return result.getVersionConstraint();
75 }
76
77 @Override
78 public int getCount() {
79 return versions.size();
80 }
81
82 @Override
83 public ArtifactRepository getRepository(Version version) {
84 return result.getRepository(version);
85 }
86
87 @Override
88 public List<RemoteRepository> getRepositories() {
89 return Collections.unmodifiableList(result.getRequest().getRepositories());
90 }
91
92 @Override
93 public Iterator<Version> iterator() {
94 return versions.iterator();
95 }
96
97 @Override
98 public String toString() {
99 return dependency + " " + result.getVersions();
100 }
101 }