001package org.eclipse.aether.internal.impl.collect; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.List; 023 024import org.eclipse.aether.RepositorySystemSession; 025import org.eclipse.aether.artifact.Artifact; 026import org.eclipse.aether.collection.DependencyCollectionContext; 027import org.eclipse.aether.graph.Dependency; 028 029/** 030 * Internal helper class for collector implementations. 031 */ 032public final class DefaultDependencyCollectionContext 033 implements DependencyCollectionContext 034{ 035 036 private final RepositorySystemSession session; 037 038 private Artifact artifact; 039 040 private Dependency dependency; 041 042 private List<Dependency> managedDependencies; 043 044 public DefaultDependencyCollectionContext( RepositorySystemSession session, Artifact artifact, 045 Dependency dependency, List<Dependency> managedDependencies ) 046 { 047 this.session = session; 048 this.artifact = ( dependency != null ) ? dependency.getArtifact() : artifact; 049 this.dependency = dependency; 050 this.managedDependencies = managedDependencies; 051 } 052 053 public RepositorySystemSession getSession() 054 { 055 return session; 056 } 057 058 public Artifact getArtifact() 059 { 060 return artifact; 061 } 062 063 public Dependency getDependency() 064 { 065 return dependency; 066 } 067 068 public List<Dependency> getManagedDependencies() 069 { 070 return managedDependencies; 071 } 072 073 public void set( Dependency dependency, List<Dependency> managedDependencies ) 074 { 075 artifact = dependency.getArtifact(); 076 this.dependency = dependency; 077 this.managedDependencies = managedDependencies; 078 } 079 080 @Override 081 public String toString() 082 { 083 return String.valueOf( getDependency() ); 084 } 085 086}