View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether.internal.impl.collect.bf;
20  
21  import java.util.List;
22  
23  import org.eclipse.aether.RequestTrace;
24  import org.eclipse.aether.collection.DependencyManager;
25  import org.eclipse.aether.collection.DependencySelector;
26  import org.eclipse.aether.collection.DependencyTraverser;
27  import org.eclipse.aether.collection.VersionFilter;
28  import org.eclipse.aether.graph.Dependency;
29  import org.eclipse.aether.graph.DependencyNode;
30  import org.eclipse.aether.internal.impl.collect.PremanagedDependency;
31  import org.eclipse.aether.repository.RemoteRepository;
32  
33  /**
34   * Internal helper for {@link BfDependencyCollector}.
35   *
36   * @since 1.8.0
37   */
38  final class DependencyProcessingContext {
39      final DependencySelector depSelector;
40      final DependencyManager depManager;
41      final DependencyTraverser depTraverser;
42      final VersionFilter verFilter;
43      final List<RemoteRepository> repositories;
44      final List<Dependency> managedDependencies;
45  
46      /**
47       * All parents of the dependency in the top > down order.
48       */
49      final List<DependencyNode> parents;
50  
51      final PremanagedDependency premanagedDependency;
52      final RequestTrace trace;
53      Dependency dependency;
54  
55      @SuppressWarnings("checkstyle:parameternumber")
56      DependencyProcessingContext(
57              DependencySelector depSelector,
58              DependencyManager depManager,
59              DependencyTraverser depTraverser,
60              VersionFilter verFilter,
61              RequestTrace trace,
62              List<RemoteRepository> repositories,
63              List<Dependency> managedDependencies,
64              List<DependencyNode> parents,
65              Dependency dependency,
66              PremanagedDependency premanagedDependency) {
67          this.depSelector = depSelector;
68          this.depManager = depManager;
69          this.depTraverser = depTraverser;
70          this.verFilter = verFilter;
71          this.trace = trace;
72          this.repositories = repositories;
73          this.dependency = dependency;
74          this.premanagedDependency = premanagedDependency;
75          this.managedDependencies = managedDependencies;
76          this.parents = parents;
77      }
78  
79      DependencyProcessingContext withDependency(Dependency dependency) {
80          this.dependency = dependency;
81          return this;
82      }
83  
84      DependencyProcessingContext copy() {
85          return new DependencyProcessingContext(
86                  depSelector,
87                  depManager,
88                  depTraverser,
89                  verFilter,
90                  trace,
91                  repositories,
92                  managedDependencies,
93                  parents,
94                  dependency,
95                  premanagedDependency);
96      }
97  
98      DependencyNode getParent() {
99          return parents.get(parents.size() - 1);
100     }
101 }