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