View Javadoc
1   package org.eclipse.aether.internal.test.util;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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  }