View Javadoc
1   package org.eclipse.aether.internal.impl.collect;
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.List;
23  
24  import org.eclipse.aether.RepositorySystemSession;
25  import org.eclipse.aether.artifact.Artifact;
26  import org.eclipse.aether.collection.DependencyCollectionContext;
27  import org.eclipse.aether.graph.Dependency;
28  
29  /**
30   * @see DefaultDependencyCollector
31   */
32  final class DefaultDependencyCollectionContext
33      implements DependencyCollectionContext
34  {
35  
36      private final RepositorySystemSession session;
37  
38      private Artifact artifact;
39  
40      private Dependency dependency;
41  
42      private List<Dependency> managedDependencies;
43  
44      DefaultDependencyCollectionContext( RepositorySystemSession session, Artifact artifact,
45                                                 Dependency dependency, List<Dependency> managedDependencies )
46      {
47          this.session = session;
48          this.artifact = ( dependency != null ) ? dependency.getArtifact() : artifact;
49          this.dependency = dependency;
50          this.managedDependencies = managedDependencies;
51      }
52  
53      public RepositorySystemSession getSession()
54      {
55          return session;
56      }
57  
58      public Artifact getArtifact()
59      {
60          return artifact;
61      }
62  
63      public Dependency getDependency()
64      {
65          return dependency;
66      }
67  
68      public List<Dependency> getManagedDependencies()
69      {
70          return managedDependencies;
71      }
72  
73      public void set( Dependency dependency, List<Dependency> managedDependencies )
74      {
75          artifact = dependency.getArtifact();
76          this.dependency = dependency;
77          this.managedDependencies = managedDependencies;
78      }
79  
80      @Override
81      public String toString()
82      {
83          return String.valueOf( getDependency() );
84      }
85  
86  }